mirror of
https://github.com/JasonYANG170/AutoCheckBJMF.git
synced 2024-11-23 12:16:25 +00:00
add git
This commit is contained in:
parent
5d07d8f22e
commit
040188dab1
59
main.py
59
main.py
|
@ -6,23 +6,24 @@ from bs4 import BeautifulSoup
|
||||||
import json
|
import json
|
||||||
import schedule
|
import schedule
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# 读取外部 JSON 文件中的数据
|
# 读取外部 JSON 文件中的数据
|
||||||
with open('data.json', 'r') as file:
|
with open('data.json', 'r') as file:
|
||||||
json_data = json.load(file)
|
json_data = json.load(file)
|
||||||
# 普通用户
|
# 普通用户
|
||||||
|
current_directory = os.getcwd()
|
||||||
|
|
||||||
print("----------提醒----------")
|
print("----------提醒----------")
|
||||||
print("项目地址:https://github.com/JasonYANG170/AutoCheckBJMF")
|
print("项目地址:https://github.com/JasonYANG170/AutoCheckBJMF")
|
||||||
print("请查看教程以获取Cookie和班级ID")
|
print("请查看教程以获取Cookie和班级ID")
|
||||||
print("提示:你可以在json文件中输入配置信息,程序将会直接导入")
|
print("data.json文件位置:", current_directory)
|
||||||
print("----------配置信息(必填)----------")
|
print("----------配置信息(必填)----------")
|
||||||
if (json_data['class'] == "123"):
|
if (json_data['class'] == "123"):
|
||||||
print("请通过查看教程抓包获取班级ID")
|
print("请通过查看教程抓包获取班级ID")
|
||||||
ClassID = input("请输入班级ID:")
|
ClassID = input("请输入班级ID:")
|
||||||
else:
|
else:
|
||||||
ClassID = json_data['class']
|
ClassID = json_data['class']
|
||||||
print("输入的经纬度格式为x.x.x")
|
print("输入的经纬度格式为x.x")
|
||||||
|
print("腾讯坐标拾取工具:https://lbs.qq.com/getPoint/")
|
||||||
if (json_data['lat'] == "123"):
|
if (json_data['lat'] == "123"):
|
||||||
X = input("请输入纬度:")
|
X = input("请输入纬度:")
|
||||||
else:
|
else:
|
||||||
|
@ -37,25 +38,64 @@ with open('data.json', 'r') as file:
|
||||||
ACC = json_data['acc'] # input("请输入海拔:")
|
ACC = json_data['acc'] # input("请输入海拔:")
|
||||||
if (json_data['time'] == 123):
|
if (json_data['time'] == 123):
|
||||||
SearchTime = int(input("请输入检索间隔,建议>=60s:"))
|
SearchTime = int(input("请输入检索间隔,建议>=60s:"))
|
||||||
|
input("配置完成,您的信息将写入json文件,下次使用将直接从json文件导入")
|
||||||
|
|
||||||
|
# 1. 读取JSON文件
|
||||||
|
# JSON文件路径
|
||||||
|
file_name = "data.json"
|
||||||
|
file_path = os.path.join(current_directory, file_name)
|
||||||
|
with open(file_path, "r") as file:
|
||||||
|
data = json.load(file)
|
||||||
|
|
||||||
|
# 2. 修改数据
|
||||||
|
data["class"] = ClassID
|
||||||
|
data["lat"] = X
|
||||||
|
data["lng"] = Y
|
||||||
|
data["acc"] = ACC
|
||||||
|
data["time"] = SearchTime
|
||||||
|
|
||||||
|
|
||||||
|
# 3. 写回JSON文件
|
||||||
|
with open(file_path, "w") as file:
|
||||||
|
json.dump(data, file, indent=4)
|
||||||
|
|
||||||
|
print("数据已保存到"+current_directory+"下的data.json中。")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
SearchTime = json_data['time'] # int(input("请输入检索时长,建议>60s:"))
|
SearchTime = json_data['time'] # int(input("请输入检索时长,建议>60s:"))
|
||||||
print("----------配置Cookie----------")
|
print("----------配置Cookie----------")
|
||||||
print("请通过查看教程抓包获取Cookie")
|
print("请通过查看教程抓包获取Cookie")
|
||||||
print("使用电脑抓取的Cookie会在电脑微信关闭时失效,失效后请重新抓取")
|
print("教程:https://github.com/JasonYANG170/AutoCheckBJMF/wiki/")
|
||||||
|
print("Tip:90%的失败由Cookie变更导致")
|
||||||
if (json_data['cookie'] == "123"):
|
if (json_data['cookie'] == "123"):
|
||||||
MyCookie = input("请输入你的Cookie:")
|
MyCookie = input("请输入你的Cookie:")
|
||||||
else:
|
else:
|
||||||
MyCookie = json_data['cookie'] # int(input("请输入检索时长,建议>60s:"))
|
MyCookie = json_data['cookie'] # int(input("请输入检索时长,建议>60s:"))
|
||||||
print("----------配置定时任务(可选)----------")
|
print("----------配置定时任务(可选)----------")
|
||||||
print("格式为00:00,不设置定时请留空")
|
print("格式为00:00,不设置定时请留空")
|
||||||
print("提示:请使用英文符号“:”不要使用中文符号“:”")
|
print("Tip:请注意以上格式并使用英文符号“:”不要使用中文符号“:”")
|
||||||
if (json_data['scheduletime'] == ""):
|
if (json_data['scheduletime'] == ""):
|
||||||
scheduletime = input("请输入开启时间:")
|
scheduletime = input("请输入开启时间:")
|
||||||
else:
|
else:
|
||||||
scheduletime = json_data['scheduletime'] # int(input("请输入检索时长,建议>60s:"))
|
scheduletime = json_data['scheduletime'] # int(input("请输入检索时长,建议>60s:"))
|
||||||
print("----------配置通知(可选)----------")
|
print("----------配置通知(可选)----------")
|
||||||
if (json_data['pushplus'] == "123"):
|
if (json_data['pushplus'] == "123"):
|
||||||
token = input("请输入pushplus密钥,不需要请留空:")
|
token = input("请输入pushplus推送密钥,不需要请留空:")
|
||||||
|
|
||||||
|
# 1. 读取JSON文件
|
||||||
|
# JSON文件路径
|
||||||
|
file_name = "data.json"
|
||||||
|
file_path = os.path.join(current_directory, file_name)
|
||||||
|
with open(file_path, "r") as file:
|
||||||
|
data = json.load(file)
|
||||||
|
|
||||||
|
# 2. 修改数据
|
||||||
|
data["pushplus"] = token
|
||||||
|
# 3. 写回JSON文件
|
||||||
|
with open(file_path, "w") as file:
|
||||||
|
json.dump(data, file, indent=4)
|
||||||
|
|
||||||
|
print("数据已保存到" + current_directory + "下的data.json中。")
|
||||||
else:
|
else:
|
||||||
token = json_data['pushplus'] # input("请输入pushplus密钥:")
|
token = json_data['pushplus'] # input("请输入pushplus密钥:")
|
||||||
print("----------信息----------")
|
print("----------信息----------")
|
||||||
|
@ -71,6 +111,7 @@ with open('data.json', 'r') as file:
|
||||||
# 输出用户输入的内容
|
# 输出用户输入的内容
|
||||||
print("程序已执行")
|
print("程序已执行")
|
||||||
|
|
||||||
|
|
||||||
# GitHub Actions自动任务
|
# GitHub Actions自动任务
|
||||||
# ClassID = os.environ['ClassID']
|
# ClassID = os.environ['ClassID']
|
||||||
# X = os.environ['X']
|
# X = os.environ['X']
|
||||||
|
@ -148,7 +189,7 @@ def job():
|
||||||
h1_text = h1_tag.text
|
h1_text = h1_tag.text
|
||||||
print(h1_text)
|
print(h1_text)
|
||||||
# encoding:utf-8
|
# encoding:utf-8
|
||||||
if(token!=""):
|
if token != "" and h1_text== "签到成功":
|
||||||
url = 'http://www.pushplus.plus/send?token=' + token + '&title=' + title + '&content=' + h1_text # 不使用请注释
|
url = 'http://www.pushplus.plus/send?token=' + token + '&title=' + title + '&content=' + h1_text # 不使用请注释
|
||||||
requests.get(url) # 不使用请注释
|
requests.get(url) # 不使用请注释
|
||||||
continue # 返回到查找进行中的签到循环
|
continue # 返回到查找进行中的签到循环
|
||||||
|
@ -162,13 +203,13 @@ def job():
|
||||||
# 可以设置一个间隔时间,避免过于频繁地请求
|
# 可以设置一个间隔时间,避免过于频繁地请求
|
||||||
time.sleep(SearchTime) # 暂停10秒后重新尝试
|
time.sleep(SearchTime) # 暂停10秒后重新尝试
|
||||||
|
|
||||||
|
|
||||||
if (scheduletime != ""):
|
if (scheduletime != ""):
|
||||||
print("等待设定时间" + scheduletime + "到达")
|
print("等待设定时间" + scheduletime + "到达")
|
||||||
# 设置定时任务,在每天的早上8点触发
|
# 设置定时任务,在每天的早上8点触发
|
||||||
schedule.every().day.at(scheduletime).do(job)
|
schedule.every().day.at(scheduletime).do(job)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
schedule.run_pending()
|
schedule.run_pending()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user