littlepythonsheep/52pojie.py
2024-03-15 10:21:11 +08:00

157 lines
5.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 吾爱破解 v1.00
#
#
# 抓取Cookie中的htVC_2132_saltkey和htVC_2132_auth
# 多账号换行隔开
# export md_ktv_cookie="htVC_2132_saltkey@htVC_2132_auth@wxpusher_uid"
#
# cron "47 10 * * *" script-path=xxx.py,tag=匹配cron用
# const $ = new Env('吾爱破解签到')
import requests
import logging
from bs4 import BeautifulSoup
import execjs
import re
import os
from wxpusher import WxPusher
pojie_cookie = os.getenv("pojie_cookie").split('\n')
# pojie_cookie = ['i655BeA4@0259LfQUV5YzmlaQOhNMuckxhQIrtvMpv%2BaMIIpW65Dj6Rv%2FrArtIp1UUAS43AyYiZv9wgwPCdFo8uEz5XPlp33lCSw1@UID_iEX04ORBuLG5ch5B3tbqBUx3G8SP']
# 获取“在测试中需要从文件中获取quicker中从变量中获取”的变量
def getParaFromFile(fileName):
try:
with open(fileName, 'r', encoding='UTF-8') as file:
result = file.read()
return result
except:
return ""
def home(saltkey1, auth1, wxpusher_uid1, check1):
session = requests.session()
logging.captureWarnings(True) # 去掉建议使用SSL验证的显示
site_url = "https://www.52pojie.cn/"
htVC_2132_auth = auth1
htVC_2132_saltkey = saltkey1
cookie = {
"htVC_2132_auth": htVC_2132_auth,
"htVC_2132_saltkey": htVC_2132_saltkey,
}
header = {
"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.52pojie.cn/",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
}
proxies = None
def start_qiandao(url):
print('result', "\n开始签到")
# 获取加密js
resp = session.get(url, headers=header, cookies=cookie, proxies=proxies, verify=False)
text = resp.text
# print(text)
pattern = r".*='([0-9]{4,})'.*='([0-9]{4,})'.*"
result = re.match(pattern, text, re.S)
# print(result)
if result:
print(result.group(1))
print(result.group(2))
else:
raise InterruptedError("没找到特征数字")
para = "var LZ ='" + result.group(1) + "',LJ='" + result.group(2) + "',"
pattern = r".*='([a-zA-Z0-9/+]{40,})'.*"
result = re.match(pattern, text, re.S)
# print(result)
if result:
print(result.group(1))
else:
raise InterruptedError("没找到加密特征")
para = para + "LE='" + result.group(1) + "';"
js = para + getParaFromFile(fileName="52pojie.js")
# print(js)
result = execjs.compile(js).call("getData")
# print(result)
# 可能这步就能签到成功
resp = session.post("https://www.52pojie.cn/waf_zw_verify", headers=header, cookies=cookie, proxies=proxies,
data=result,
verify=False)
# print(resp.status_code)
# print(resp.text)
resp = session.get(url, headers=header, cookies=cookie, proxies=proxies, verify=False)
# print(resp.status_code)
# print(resp.text)
home(saltkey1, auth1, wxpusher_uid1, True)
response = session.get(url=site_url, cookies=cookie, headers=header, proxies=proxies, verify=False)
# print(response.text)
soup = BeautifulSoup(response.text)
login = soup.find('button', class_="pn vm")
# print(soup.prettify())
# print(login is None)
content = "吾爱破解签到结果:"
if login is None:
qiandao = list(filter(lambda node: node.get("src").endswith("qds.png") or node.get("src").endswith("wbs.png"),
soup.findAll('img', class_="qq_bind")))
if qiandao is None or len(qiandao) == 0:
print('result', "\n获取签到标志失败")
return
qiandao = qiandao[0]
# qds.png 为未签到 wbs为签到
if qiandao.get("src").endswith("qds.png"):
print('result', "\n未签到")
content += "未签到"
if check1 is False:
start_qiandao(site_url + qiandao.parent.get("href"))
else:
print('result', "\n已签到")
content += "已签到"
else:
print('result', "\n登录失效请更新cookie中的htVC_2132_auth、htVC_2132_saltkey")
content += "登录失效请更新cookie中的htVC_2132_auth、htVC_2132_saltkey"
WxPusher.send_message(content,
uids=[wxpusher_uid1],
token='AT_uj0Ezms54MZVD3xO5R5i1Wh3vR7nMety')
if __name__ == '__main__':
# 遍历所有帐号
for i in range(len(pojie_cookie)):
cookies = pojie_cookie[i]
saltkey = cookies.split('@')[0]
auth = cookies.split('@')[1]
# 判断是否有推送uid
if len(cookies.split('@')) == 3:
wxpusher_uid = cookies.split('@')[2]
else:
wxpusher_uid = ''
print(f'开始第{i + 1}个帐号签到')
check = False
home(saltkey, auth, wxpusher_uid, check)