代码优化
This commit is contained in:
parent
f5e738d6ee
commit
128cf68678
|
@ -36,7 +36,7 @@ class PtOperation:
|
|||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
||||
}
|
||||
|
||||
def attendances(self, section_name, url, cookie):
|
||||
def attendances(self, section_name, section_data):
|
||||
"""
|
||||
签到
|
||||
:param section_name:
|
||||
|
@ -45,28 +45,39 @@ class PtOperation:
|
|||
:return:
|
||||
"""
|
||||
res_txt = f"开始对 [{section_name}] 进行签到操作...,签到结果:"
|
||||
url, cookie, attendance_uri = section_data.get('url'), section_data.get('cookie'), section_data.get(
|
||||
'attendance_uri')
|
||||
self.headers["cookie"] = cookie
|
||||
request_url = url + "/attendance.php"
|
||||
# cookie不为空时候,可以签到
|
||||
if cookie is not None and len(cookie.strip()) > 0:
|
||||
# 获取网站自定义的签到链接
|
||||
attendance_uri = section_data.get('attendance_uri')
|
||||
if attendance_uri is not None and len(attendance_uri.strip()) > 0:
|
||||
url = url + attendance_uri
|
||||
else:
|
||||
url = url + "/attendance.php"
|
||||
for _ in range(5):
|
||||
try:
|
||||
response_result = requests.get(request_url, headers=self.headers)
|
||||
if '签到成功' in response_result.text or '已签到' in response_result.text:
|
||||
response_result = requests.get(url, headers=self.headers)
|
||||
if response_result.status_code == 200:
|
||||
res_txt = res_txt + '签到成功!'
|
||||
logger.info(res_txt)
|
||||
break
|
||||
except Exception as e:
|
||||
time.sleep(2)
|
||||
else:
|
||||
logger.error(f"{res_txt} 5次出现错误,请关注!!!")
|
||||
res_txt = res_txt + f"{res_txt} 5次出现错误,请关注!!!{url}"
|
||||
logger.error(res_txt)
|
||||
pushme("签到错误提示:" + section_name, res_txt)
|
||||
pushplus_bot("签到错误提示:" + section_name, res_txt)
|
||||
self.headers["cookie"] = ""
|
||||
|
||||
def signup(self, section_name, url):
|
||||
def signup(self, section_name, section_data):
|
||||
"""
|
||||
是否开注册
|
||||
:return:
|
||||
"""
|
||||
url = section_data.get('url')
|
||||
request_url = url + "/signup.php"
|
||||
text = f"网站名:{section_name}, 网址:{request_url}"
|
||||
logger.info(f"开始 -->> {text}")
|
||||
|
@ -138,15 +149,10 @@ class PtOperation:
|
|||
print(f"Processing section: {section_name} --- {section_data.get('url')}")
|
||||
url, cookie, flag = section_data.get('url'), section_data.get('cookie'), section_data.get('flag')
|
||||
if flag != 1:
|
||||
if len(cookie.strip()) > 0:
|
||||
# cookie不为空时候,可以签到
|
||||
# 获取网站自定义的签到链接
|
||||
attendance_uri = section_data.get('attendance_uri')
|
||||
if len(attendance_uri.strip()) > 0:
|
||||
url = url + attendance_uri
|
||||
self.attendances(section_name, url, cookie)
|
||||
# 签到
|
||||
self.attendances(section_name, section_data)
|
||||
# 检测是否可以注册
|
||||
self.signup(section_name, url)
|
||||
self.signup(section_name, section_data)
|
||||
except FileNotFoundError:
|
||||
print(f"Error: The file '{self.toml_file}' was not found.")
|
||||
except toml.TomlDecodeError as e:
|
||||
|
|
38
PT/test.py
38
PT/test.py
|
@ -1,8 +1,6 @@
|
|||
import json
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
url = "https://www.hddolby.com/signup.php"
|
||||
headers = {
|
||||
'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.7',
|
||||
'accept-language': 'zh,zh-CN;q=0.9',
|
||||
|
@ -16,34 +14,10 @@ headers = {
|
|||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1',
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
||||
"Referer": url
|
||||
}
|
||||
|
||||
response = requests.get(url, headers=headers, timeout=60)
|
||||
print(f"{response.status_code}, {type(response.status_code)} , {response.status_code == 403}")
|
||||
print(response.text in "Just a moment")
|
||||
# flaresolverr_url = "http://152.136.50.100:7024/v1"
|
||||
# payload = json.dumps({
|
||||
# "cmd": "request.get",
|
||||
# "url": url + "/signup.php",
|
||||
# "maxTimeout": 60000
|
||||
# })
|
||||
# headers = {
|
||||
# 'Content-Type': 'application/json'
|
||||
# }
|
||||
# response = requests.post(flaresolverr_url, headers=headers, data=payload)
|
||||
# # response = '{"status": "ok", "message": "Challenge solved!", "solution": {"url": "https://piggo.me/login.php", "status": 200, "cookies": [{"domain": "piggo.me", "expiry": 1703640561, "httpOnly": true, "name": "sl-session", "path": "/", "sameSite": "None", "secure": true, "value": "7BrzKfF9i2XQp+tXKV6Arw=="}, {"domain": ".piggo.me", "expiry": 1735090161, "httpOnly": true, "name": "cf_clearance", "path": "/", "sameSite": "None", "secure": true, "value": "gvbnoRfMbANgSnxTUAW_lLVeAX.Nzr.8rJNR0yFgDv0-1703554148-0-2-76d08d10.6cf0fe2.27f806e8-250.0.0"}], "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "headers": {}, "response": ""}, "startTimestamp": 1703554142434, "endTimestamp": 1703554164365, "version": "3.3.12"}'
|
||||
# print(response.text)
|
||||
# res = json.loads(response.text)
|
||||
# if res['status'] == 'ok' and res['solution']['status'] == 200:
|
||||
# user_agent = res['solution']['userAgent']
|
||||
# cookies = res['solution']['cookies']
|
||||
# html = res['solution']['response']
|
||||
# soup = BeautifulSoup(html, 'html.parser')
|
||||
# # 获取class为'text'的元素的文字内容
|
||||
# text_content = soup.find(class_='text').get_text()
|
||||
# # 打印结果
|
||||
# if "再次输入密码" in text_content or "submit" in text_content:
|
||||
# print(f"现在 {url} 正在开放注册,请前往~!")
|
||||
# else:
|
||||
# print(text_content)
|
||||
cookie = "c_secure_uid=MTk0OTI%3D; c_secure_pass=d7f655d5b8e90739f23620b9d24241e1; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D; PHPSESSID=em8dtq7r0t77tt1e0aq4m0of1o"
|
||||
headers["cookie"] = cookie
|
||||
url = "https://www.icc2022.com/attendance.php"
|
||||
response_result = requests.get(url, headers=headers)
|
||||
print(response_result.status_code)
|
||||
print(response_result.text)
|
Loading…
Reference in New Issue