ctfhub每日签到

文章介绍了如何用Python编写一个脚本来调用CTFHub的API进行用户签到,并将签到信息写入日志文件。此外,还展示了如何创建bat文件和将其设置为Windows开机自启动。
摘要由CSDN通过智能技术生成

1.python实现

import time
import os
from datetime import datetime
import requests
headers = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
!!!!!!
    "Authorization": "ctfhub_sessid=这不能给你", 
    "Connection": "keep-alive",
    "Content-Type": "application/json;charset=UTF-8",
    "Host": "api.ctfhub.com",
    "Origin": "https://www.ctfhub.com",
    "Referer": "https://www.ctfhub.com/",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-site",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0",
}
# Replace with your actual request data (if applicable)
request_data = {}  # Example: {"key": "value"}

# Make the POST request
response = requests.post(
    "https://api.ctfhub.com/User_API/User/checkIn",
    headers=headers,
    json=request_data  # Use json= if sending JSON data
)
response_j = response.json()
print(response_j)
print("!!!窗口将在3秒后关闭!!! :)")
time.sleep(3)
now = datetime.now()
dt_string = now.strftime("%Y-%m-%d %H:%M:%S")
# 要写入的内容
content = f"{dt_string}---{response_j}"
# 写入文件
file_path = r"D:\yzzob\Desktop\ctfhub\logs.txt"
with open(file_path, "r")as  file:
    lines = file.readlines()
    if lines:
        last_line = lines[-1].strip()
if last_line and last_line.startswith(dt_string[:10]):
    print("今天已经写入过日志,不需要再写入了。")
else:
    # 写入文件
    with open(file_path, "a") as file:
        file.write(content + "\n")

2.生成bat文件和logs.txt

@echo off
python D:\1\mainpyproject\important\ctfhubcheckin.py
exit

#如果安装了多python版本可用地址指定python版本
@echo off
D:\python\python.exe D:\1_pyproject\important\ctfhubcheckin.py
exit

3.

放到目录C:\Users\yzz\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

生成快捷方式

参考:

Windows-bat或exe文件设置为开机自动启动项或服务项_bat开机自启动-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值