精易论坛

标题: python签到脚本_某论坛-sign [打印本页]

作者: uga353    时间: 2024-10-15 01:23
标题: python签到脚本_某论坛-sign
  
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import re
import sys
import urllib.parse
import random
from time import sleep
import requests
from bs4 import BeautifulSoup
import notify
# class notify:
#     @staticmethod
#     def send (title, content):
#         print (f"{title}: {content}")
sleep_time = [100, 200]  # 随机等待时间默认在100-200秒之间
# 多cookie使用&分割
token = os.environ.get ("xxx_TOKEN")
if not token:
print ("请在环境变量填入xxx_TOKEN的值")
sys.exit ()
cookies = ' '
if cookies == "":
if os.environ.get ("xxx_COOKIE"):
cookies = os.environ.get ("xxx_COOKIE")
else:
print ("请在环境变量填写xxx_COOKIE的值")
sys.exit ()
n = 1
for cookie in cookies.split ("&"):
sleep (random.randint (sleep_time[0], sleep_time[1]))
url1 = ' https://www.xxx.cn/'
url2 = ' https://www.xxx.cn/home.php?mod=task&do=apply&id=2&referer=%2F'
# url3 = ' https://www.xxx.cn/home.php?mod=task&do=draw&id=2'
url4 = ' https://www.xxx.cn/waf_zw_verify'
cookie = urllib.parse.unquote (cookie)
cookie_list = cookie.split (";")
cookie = ' '
cookie = { ' htVC_2132_auth': '',
' htVC_2132_saltkey': ''}
for i in cookie_list:
key = i.split ("=")[0]
if "htVC_2132_saltkey" in key:
cookie[ ' htVC_2132_saltkey'] = urllib.parse.quote(i.split("=")[1])
if "htVC_2132_auth" in key:
cookie[ ' htVC_2132_auth'] = urllib.parse.quote(i.split("=")[1])
if cookie[ ' htVC_2132_saltkey'] == '' or cookie['htVC_2132_auth'] == '':
print (f"第{n}cookie中未包含htVC_2132_saltkey或htVC_2132_auth字段,请检查cookie")
sys.exit ()
headers = {
"Connection": "keep-alive",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-User": "?1",
"Sec-Fetch-Dest": "document",
"sec-ch-ua": "\"Chromium\";v=\"104\", \" Not A;Brand\";v=\"99\", \"Google Chrome\";v=\"104\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"Referer": "https://www.xxx.cn/",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
}
session = requests.session ()
r = session.get (url1, headers=headers, cookies=cookie)
# print (r.text)
soup = BeautifulSoup (r.text,features="html.parser")
login = soup.find ( ' button', class_="pn vm")
# print (login)
if login != None:
print (f"第{n}个账号Cookie 失效")
message = f"第{n}个账号Cookie 失效"
n += 1
continue
sign_check = list (filter (lambda node: node.get ("src").endswith ("qds.png") or node.get ("src").endswith ("wbs.png"),
soup.findAll ( ' img', class_="qq_bind")))
if sign_check is None or len (sign_check) == 0:
print (f"第{n}个账号Cookie 失效")
message = f"第{n}个账号Cookie 失效"
n += 1
continue
sign_check = sign_check[0]
if not sign_check.get ("src").endswith ("qds.png"):
print (f"第{n}个账号今日已签到")
message = f"第{n}个账号今日已签到"
n += 1
continue
r = session.get (url2, headers=headers, cookies=cookie)
pattern = r".*= ' ([0-9]{4,})'.*='([0-9]{4,})'.*"
result = re.match (pattern, r.text, re.S)
if not result:
print (f"第{n}个账号今日签到失败")
message = f"第{n}个账号今日签到失败"
n += 1
continue
lz = result.group (1)
lj = result.group (2)
pattern = r".*= ' ([a-zA-Z0-9/+]{40,})'.*"
result = re.match (pattern, r.text, re.S)
if not result:
print (f"第{n}个账号今日签到失败")
message = f"第{n}个账号今日签到失败"
n += 1
continue
le = result.group (1)
result = requests.post ("https://xxx-sign-sever.zzboy.tk/api/xxx",json={"lz": lz, "lj": lj, "le": le,"token":token})
if result.status_code != 200:
print (result.json ()[ ' msg'])
print ("请前往https://zhustatus.azurewebsites.net/查看“xxx-SIGN”的运行状态")
sys.exit ()
# print (result.text)
r = session.post (url4, headers=headers, cookies=cookie, data=result.text, proxies=None)
# print (r.text)
r = session.get (url2, headers=headers, cookies=cookie)
# print (r.status_code, r.text)
r_data = BeautifulSoup (r.text, "html.parser")
# print (r_data)
jx_data = r_data.find ("div", id="messagetext").find ("p").text
if "您需要先登录才能继续本操作" in jx_data:
print (f"第{n}个账号Cookie 失效")
message = f"第{n}个账号Cookie 失效"
elif "恭喜" in jx_data:
print (f"第{n}个账号签到成功")
message = f"第{n}个账号签到成功"
elif "不是进行中的任务" in jx_data:
print (f"第{n}个账号今日已签到")
message = f"第{n}个账号今日已签到"
else:
print (f"第{n}个账号签到失败")
message = f"第{n}个账号签到失败"
n += 1
notify.send ("签到", message)



作者: 沙漠之丘    时间: 2024-10-15 01:49

支持6666666666666666666
作者: 曲终人散啊    时间: 2024-10-15 03:10
支持一下。
作者: renhe2018    时间: 2024-10-15 03:29
厉害了,支持。
作者: 一指温柔    时间: 2024-10-15 08:59
感谢分享
作者: xujunfengswxj    时间: 2024-10-15 10:06

作者: 396384183    时间: 2024-10-15 11:24

大佬nb66666666666666666
作者: wjswzj0    时间: 2024-10-15 11:50
感谢分享
作者: bianyuan456    时间: 2024-10-15 12:35
已经顶贴,感谢您对论坛的支持!
作者: xiaomeng0    时间: 2024-10-15 14:05
没看出来是哪个论坛呢
作者: 咔咔云    时间: 2024-10-15 18:22
52pojie的?
作者: winzsy    时间: 2024-10-15 20:59
感谢楼主分享
作者: year1970    时间: 2024-10-16 07:56
感谢分享
作者: 何浩文    时间: 2024-10-16 11:37
支持开源~!感谢分享
作者: aiboboxx    时间: 2024-10-20 19:39
感谢分享!!!GFNV0OlSEB
作者: aiboboxx    时间: 2024-10-21 07:42
感谢分享!!!vvXnStdF0u
作者: yuzhong    时间: 2024-10-26 21:16
111111111111111111111111111111111111
作者: 爱网久久    时间: 2024-10-28 21:47
感谢分享,很给力!
作者: 果心豆腐酱    时间: 2024-11-10 10:05
xxx_TOKEN是什么值阿
作者: 熊不熊    时间: 2024-12-4 08:23
感谢分享,很给力!~




欢迎光临 精易论坛 (https://125.confly.eu.org/) Powered by Discuz! X3.4