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
生成快捷方式
参考: