加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
laborWechatScore.py 4.11 KB
一键复制 编辑 原始数据 按行查看 历史
B2FH 提交于 2024-06-05 20:18 . 劳动竞赛初版
import json
import requests
import random
import time
url = "https://mt.fjii.com/api/wechatShareTask/shareSum"
# 获取从键盘输入的值赋值给userId和token
with open('token.json', 'r') as f:
userInfo = json.load(f)
print(userInfo)
userId = userInfo['id']
token = userInfo['token']
# userId = input("请输入userId:")
print(userId)
# token = input('请输入token:')
print(token)
# token = "074fc07a-279a-4ebb-b5e5-54c01533457e"
# userId = 1684743956111429632
# payload="{\"isLoadTip\":\"...\",\"user_id\":\"1316927879329746944\",\"wechat_share_task_id\":\"1414761988562751488\",\"type\":2,\"token_header\":\"xOjqTc9vix%2FIQVwVMZmkpCwp4B2WafoeT991Rnx%2FJhmYF6H9Xv46EkHqmsU%2BjVVIZyeIygoJ8sDqdM7d4AfPy19p0ULjujQFFQMUEzFwNVRNw%2FJo8ou6CGPkfB%2B%2FLMlgX2y%2BudFF9SrsZ5kWvffVJg%3D%3D\"}"
headers = {
'POSThttps': '//mt.fjii.com/api/wechatShareTask/shareSumHTTP/1.1',
'Host': 'mt.fjii.com',
'Connection': 'keep-alive',
'Content-Length': '302',
'Accept': 'application/json,text/plain,*/*',
'User-Agent': 'Mozilla/5.0(Linux;Android10;ALP-AL00Build/HUAWEIALP-AL00;wv)AppleWebKit/537.36(KHTML,likeGecko)Version/4.0Chrome/83.0.4103.106MobileSafari/537.36wpsystem',
'Content-Type': 'application/json;charset=UTF-8',
'Origin': 'https://mt.fjii.com',
'X-Requested-With': 'com.fuzhou.wpsystem',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Accept-Encoding': 'gzip,deflate',
'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
'Cookie': f'token={token}'
}
# 从ids.json文件中读取id
with open('laborIds.json', 'r') as f:
ids = json.load(f)
# payload="{\"isLoadTip\":\"...\",\"user_id\":\"1684743956111429632\",\"wechat_share_task_id\":\""
payload = "{\"isLoadTip\":\"...\",\"user_id\":" + \
f"{userId}"+",\"wechat_share_task_id\":\""
# 从nums.json文件中读取上次刷到的id
with open('nums.json', 'r') as f:
nums_init = json.load(f)
#
# nums = nums_init
laborWechatNum = nums_init['laborWechatNum']
for i in range(laborWechatNum, len(ids)):
end = "\",\"type\":1,\"appVersion\":\"2.9.10\"}"
# end="\",\"type\":1,\"token_header\":\"xOjqTc9vix%2FIQVwVMZmkpCwp4B2WafoeT991Rnx%2FJhmYF6H9Xv46EkHqmsU%2BjVVIZyeIygoJ8sDqdM7d4AfPy19p0ULjujQFFQMUEzFwNVRNw%2FJo8ou6CGPkfB%2B%2FLMlgX2y%2BudFF9SrsZ5kWvffVJg%3D%3D\"}"
payloads = payload+ids[i]+end
# print(payloads)
try:
response = requests.request("POST", url, headers=headers, data=payloads)
except Exception as error:
#抓取异常信息,存储到log.txt文件中
with open('log.txt', 'a') as f:
f.write(f"{error}\n")
# 将laborWechatNum更新后存入json文件
nums_init['laborWechatNum'] = laborWechatNum
with open('nums.json', 'w') as f:
json.dump(nums_init, f)
print("出现错误,程序终止")
break
print(response.text)
res_text = response.text
if res_text.find("分享成功") == -1:
if res_text.find("成功") != -1:
with open('log.txt', 'a') as f:
f.write(f"{res_text}token过期\n")
print("token过期")
break
if res_text.find("频繁分享") != -1:
print("频繁分享,程序休眠10分钟")
# 将nums存入json文件
nums_init['laborWechatNum'] = laborWechatNum
with open('nums.json', 'w') as f:
json.dump(nums_init, f)
# 休眠601秒并显示倒计时
for i in range(601):
print(f"程序将在{601-i}秒后继续执行", end="\r")
time.sleep(1)
else:
#抓取异常信息
with open('log.txt', 'a') as f:
f.write(f"{res_text}程序错误,终止执行\n")
# 将nums存入json文件
with open('nums.json', 'w') as f:
json.dump(nums_init, f)
break
# 生成随机数
time.sleep(random.randint(1, 2))
print(laborWechatNum)
laborWechatNum = laborWechatNum+1
# 将nums存入json文件
with open('nums.json', 'w') as f:
json.dump(nums_init, f)
print("刷分结束")
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化