* 'master' of https://gitea.qnloft.com/qnloft/qnloft-spider:
  提交变更
This commit is contained in:
rm 2023-12-26 09:53:23 +08:00
commit 347b2a8dd9
5 changed files with 807 additions and 694 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,20 @@
# 说明:
# level表示站点的等级或者大小程度等级越高站点规模越大
# type 表示站点的类型 9kg=18禁,
[m-team]
url = "https://kp.m-team.cc/login.php"
['鲨鱼PT']
url = "https://sharkpt.net"
cookie = ""
level = 1
level = 3
['杜比PT']
url = "https://www.hddolby.com"
cookie = ""
level = 3
['自由农场PT']
url = "https://pt.0ff.cc"
cookie = ""
level = 3
[pttime]
url = "https://www.pttime.com"
@ -21,11 +31,6 @@ url = "https://www.icc2022.com"
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"
level = 3
[soulvoice]
url = "https://pt.soulvoice.club"
cookie = ""
level = 4
[hdmayi]
url = "https://www.hdmayi.com"
cookie = "Hm_lvt_6d8ca12c6bcfbd37eefefe2acf29b40d=1701424866; c_secure_uid=MjcyODg%3D; c_secure_pass=4e745ac26cb64631db97c605af6eef25; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D; Hm_lpvt_6d8ca12c6bcfbd37eefefe2acf29b40d=1701832678"

View File

@ -1,34 +1,103 @@
import sys
from loguru import logger
import time
import requests
import toml
import cloudscraper
'''
new Env('PT自动签到和注册检测');
8 8 2 1 * https://raw.githubusercontent.com/6dylan6/auto_comment/main/jd_comment.py
'''
"""
需求
1. 整理有价值的PT站点放入 pt_config.toml
2. 检测这些站点是否可以注册每8小时扫描一次
3. 自动签到 cookie 有数据的网站每天执行一次
"""
class PtOperation:
def __init__(self,url):
self.config = 'pt_config.toml'
self.url = url
def __init__(self):
logger.add("../log/PtOperation.log", rotation="500 MB", level="INFO")
logger.add(sys.stderr, level="INFO")
self.toml_file = 'pt_config.toml'
self.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',
'cache-control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-origin',
'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',
}
def attendances(self):
request_url = self.url + "/attendance.php"
def signup(self):
request_url = self.url + "/signup.php"
def attendances(self, section_name, url, cookie):
"""
签到
:param section_name:
:param cookie:
:param url:
:return:
"""
res_txt = f"开始对 [{section_name}] 进行签到操作...,签到结果:"
self.headers["cookie"] = cookie
request_url = url + "/attendance.php"
for _ in range(5):
try:
response_result = requests.get(request_url, headers=self.headers)
if '签到成功' in response_result.text:
res_txt = res_txt + '签到成功!'
break
except Exception as e:
res_txt = res_txt + '签到出错!'
time.sleep(1)
else:
logger.error(f"5次出现错误请关注")
logger.info(res_txt)
def signup(self, section_name, url):
"""
是否开注册
:return:
"""
request_url = url + "/signup.php"
text = f"网站名:{section_name}, 网址:{request_url}"
scraper = cloudscraper.create_scraper(browser='chrome', debug=True, delay=10)
for _ in range(5):
try:
response_result = scraper.get(url=request_url).text
logger.info(text)
logger.info(response_result)
break
except Exception as e:
time.sleep(2)
else:
logger.error(f"{text} , 5次出现错误无法访问")
logger.info("=" * 100)
def opt(self):
try:
with open(self.toml_file, 'r', encoding='utf-8') as file:
config_data = toml.load(file)
# 迭代每个 section
for section_name, section_data in config_data.items():
print(f"Processing section: {section_name} --- {section_data.get('url')}")
url, cookie = section_data.get('url'), section_data.get('cookie')
if len(cookie.strip()) > 0:
pass
# 签到
# self.attendances(section_name, url, cookie)
else:
# 检测是否可以注册
self.signup(section_name, url)
except FileNotFoundError:
print(f"Error: The file '{self.toml_file}' was not found.")
except toml.TomlDecodeError as e:
print(f"Error decoding TOML: {e}")
try:
with open(config_file_path, 'r') as file:
config_data = toml.load(file)
# 迭代每个 section
for section_name, section_data in config_data.items():
print(f"Processing section: {section_name} --- {section_data.get('url')}")
except FileNotFoundError:
print(f"Error: The file '{config_file_path}' was not found.")
except toml.TomlDecodeError as e:
print(f"Error decoding TOML: {e}")
if __name__ == '__main__':
PtOperation().opt()

0
PT_main.py Normal file
View File

30
log/PtOperation.log Normal file

File diff suppressed because one or more lines are too long