修改部分bug

This commit is contained in:
rm 2024-03-01 16:57:33 +08:00
parent 5ff40f4711
commit 3b465b1c78
6 changed files with 32 additions and 309 deletions

View File

@ -60,26 +60,23 @@ url = "https://1ptba.com"
cookie = "c_secure_uid=MTA0ODQx; c_secure_pass=c32037fc1a670e75d797df403e9e5a33; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D"
level = 3
label = "游戏、综艺、电子书、windows软件"
flag = 1
[icc2022]
['icc2022']
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
label = "动漫、综艺、电视剧"
flag = 1
# ===========================【end】 nastools 合作站点 【end】===========================
# ===========================【start】 9kg 站点 【start】===========================
[pttime]
['pttime']
url = "https://www.pttime.org"
cookie = "c_lang_folder=chs; c_secure_uid=OTExNDU%3D; c_secure_pass=b4567a9950c3906657ed8baeb5a39b2d; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D; cf_clearance=RtffM86J.2AMKNqMKcF5WTGWOK11V7gklzY2rDRNu24-1701826018-0-1-d71c894c.1d67b4d8.801dd6ac-0.2.1701826018"
level = 2
label = "9kg"
flag = 1
[2xfree]
['2xfree']
url = "https://pt.2xfree.org"
cookie = ""
level = 2
@ -208,7 +205,7 @@ cookie = ""
level = 3
label = "影视,有声书,音乐,综合"
[btschool]
['btschool']
url = "https://pt.btschool.club"
cookie = "cf_clearance=jF00JzyDrgabpWNeI.lugDevna4ve32DaZmrQRdaCT0-1704082342-0-2-a3ff971.dfaafd78.5d3ea691-150.0.0; c_secure_uid=MTM4NTQ2; c_secure_pass=8ecd3e82fe5489fac4d6cda2a9ba1839; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D"
attendance_uri = "/index.php?action=addbonus"

View File

@ -152,9 +152,9 @@ class PtOperation:
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, flag = section_data.get('url'), section_data.get('cookie'), section_data.get('flag')
if flag != 1:
print(f"Processing section: {section_name} --- {section_data.get('url')}")
# 签到
self.attendances(section_name, section_data)
# 检测是否可以注册
@ -164,6 +164,3 @@ class PtOperation:
except toml.TomlDecodeError as e:
print(f"Error decoding TOML: {e}")
if __name__ == '__main__':
PtOperation().signup("icc2022", "https://www.icc2022.com")

View File

@ -1,159 +0,0 @@
<bodv>
<table class="head" cellspacing="g" cellpadding="g" align="center">..</table>
<table class="mainouter" width="g82" cellspacing="g" cellpadding="5" align="center">
<tbody>
<tr></tr>
<tr>
<td id="outer" align="center" class="outer" style="padding-top: 20px; padding-bottom: 20px">
<div align="center" style="margin-bottom: 10px" id="ad belownav"></div>
<table width="1080" class="main" border="g" cellspacing="g" cellpadding="g">
<tbody>
<tr>
<td class="embedded">
<form method="get' name=" searchbox" action="?">.</form>
<div align="center" style="margin-top: 10px" id="ad belowsearchbox"></div>
<p align="center">.</p>
<p align="center">.</p>
<table class="torrents" cellspacing="g" cellpadding="5" width="100%">
<tr>
<td class="colhead" style="padding: 0px">类型</td>
<td class="colhead">
<a href="?sort=1&amp;type=asc">标题</a>
</td>
<td class="colhead">
<a href="?sort=3&amp;type=desc">
<img class="comments" src="pic/trans.gif" alt="comments" title="评论数" />
</a>
</td>
<td class="colhead">
<a href="?sort=4&amp;type=desc">
<img class="time" src="pic/trans.gif" alt="time" title="存活时间" />
</a>
</td>
<td class="colhead">
<a href="?sort=5&amp;type=desc">
<img class="size" src="pic/trans.gif" alt="size" title="大小" />
</a>
</td>
<td class="colhead">
<a href="?sort=7&amp;type=desc">
<img class="seeders" src="pic/trans.gif" alt="seeders" title="种子数" />
</a>
</td>
<td class="colhead">
<a href="?sort=8&amp;type=desc">
<img class="leechers" src="pic/trans.gif" alt="leechers" title="下载数" />
</a>
</td>
<td class="colhead">
<a href="?sort=6&amp;type=desc">
<img class="snatched" src="pic/trans.gif" alt="snatched" title="完成数" />
</a>
</td>
<td class="colhead">
<a href="?sort=9&amp;type=desc">发布者</a>
</td>
</tr>
<tr>
<td class="rowfollow nowrap" valign="middle" style='padding: 0px'>
<a href="?cat=405">
<img class="c_movie" src="pic/cattrans.gif" alt="电影/Movies" title="电影/Movies" style="background-image: url(pic/category/chd/scenetorrents/chs/catsprites.png);" />
</a>
<img src="pic/cattrans.gif" style="background-image: url(pic/category/chd/scenetorrents/chs/additional/encode.png);" alt="encode" title="encode" />
</td>
<td class="rowfollow" width="100%" align="left">
<table class="torrentname" width="100%">
<tr>
<td class="embedded">
<img class="top0" src="pic/trans.gif" alt="Sticky" title="一级置顶" />
&nbsp;
<a title="The Man in the Iron Mask 1998 Blu-ray 1080p x264 DTS-HD MA 5.1-BtsHD" href="details.php?id=130681&amp;hit=1">
<b>The Man in the Iron Mask 1998 Blu-ray 1080p x264 DTS-HD MA 5.1-BtsHD</b>
</a>
<b>
[<font class='hot'>热门</font>
]
</b>
<img class="pro_free" src="pic/trans.gif" alt="Free" onmouseover="domTT_activate(this, event, 'content', '&lt;b&gt;&lt;font class=&quot;free&quot;&gt;免费&lt;/font&gt;&lt;/b&gt;剩余时间:&lt;b&gt;&lt;span title=&quot;2024-01-18 22:24:08&quot;&gt;3天7时&lt;/span&gt;&lt;/b&gt;', 'trail', false, 'delay',500,'lifetime',3000,'fade','both','styleClass','niceTitle', 'fadeMax',87, 'maxWidth', 300);" />
(
<font color='#0000FF'>
剩余时间:<span title="2024-01-18 22:24:08">3天7时</span>
</font>
)
<br />
<span class="label label-primary">官方</span>
铁面人
<div class="progressarea" title="做种中">
<img src="styles/progress_seeding.gif" />
<div class="progress">
<div class="progress_seeding" style="width:100%;"></div>
</div>
</div>
</td>
<td width="50" class="embedded" style="text-align: left; " valign="middle">
<div>
<img src="pic/icon-douban.png" style='padding-bottom: 2px;vertical-align:middle;height: 16px;' alt="豆瓣评分" title="豆瓣评分" />&nbsp;&nbsp;
</div>
<div>
<img src="pic/icon-imdb.png" style='padding-bottom: 2px;vertical-align:middle;height: 16px;' alt="IMDB评分" title="IMDB评分" />&nbsp;&nbsp;
</div>
</td>
<td width="20" class="embedded" style="text-align: right; " valign="middle">
<a href="download.php?id=130681">
<img class="download" src="pic/trans.gif" style='padding-bottom: 2px;' alt="download" title="下载本种" />
</a>
<br />
<a id="bookmark0" href="javascript: bookmark(130681,0);">
<img class="delbookmark" src="pic/trans.gif" alt="Unbookmarked" title="收藏" />
</a>
</td>
</tr>
</table>
</td>
<td class="rowfollow">
<a href="" title="添加评论">0</a>
</td>
<td class="rowfollow nowrap">
<span title="2024-01-13 22:24:08">
1天
<br />16时
</span>
</td>
<td class="rowfollow">
11.17
<br />GB
</td>
<td class="rowfollow" align="center">
<b>
<a href="details.php?id=130681&amp;hit=1&amp;dllist=1#seeders">123</a>
</b>
</td>
<td class="rowfollow">
<b>
<a href="details.php?id=130681&amp;hit=1&amp;dllist=1#leechers">2</a>
</b>
</td>
<td class="rowfollow">
<a href="viewsnatches.php?id=130681">
<b>246</b>
</a>
</td>
<td class="rowfollow">
<i>匿名</i>
</td>
</tr>
</table>
<p align="center">.</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div id="footer'></div>
<span id=" pinbox-extension-installed">
</span>
</body>

View File

@ -1,139 +0,0 @@
import time
from datetime import datetime
import pandas as pd
import requests
import sqlalchemy
import toml
from lxml import html as lhtml
from urllib.parse import urlparse, parse_qs
from sqlalchemy.orm import attributes
from sqlalchemy import func
from qnloft_db.sqlite_db_main import SqliteDbMain
from qnloft_db_model.PtWebsiteData import PtWebsiteData
from dateutil import parser
from qnloft_db import db_config as config
def extract_id(url, field) -> bytes:
parsed_url = urlparse(url)
query_params = parse_qs(parsed_url.query)
return query_params.get(field, [None])[0]
def contains_alpha_or_chinese(input_str):
s = input_str.strip()
# 判断是否包含字母
has_alpha = any(char.isalpha() for char in s)
# 判断是否包含汉字
has_chinese = any('\u4e00' <= char <= '\u9fff' for char in s)
# 返回结果
return s if has_alpha or has_chinese else None
def check_seed_status(status):
s = ["%", "Free", "free"]
return status if any(keyword in status for keyword in s) else None
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',
}
section_name = 'icc2022'
# 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"
# url = "https://www.icc2022.com"
# url = "https://1ptba.com"
# cookie = "c_secure_uid=MTA0ODQx; c_secure_pass=c32037fc1a670e75d797df403e9e5a33; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D"
url = "https://pt.btschool.club"
cookie = "cf_clearance=jF00JzyDrgabpWNeI.lugDevna4ve32DaZmrQRdaCT0-1704082342-0-2-a3ff971.dfaafd78.5d3ea691-150.0.0; c_secure_uid=MTM4NTQ2; c_secure_pass=8ecd3e82fe5489fac4d6cda2a9ba1839; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D"
# url = "https://www.pttime.org"
# cookie = "c_lang_folder=chs; c_secure_uid=OTExNDU%3D; c_secure_pass=b4567a9950c3906657ed8baeb5a39b2d; c_secure_ssl=eWVhaA%3D%3D; c_secure_tracker_ssl=eWVhaA%3D%3D; c_secure_login=bm9wZQ%3D%3D; cf_clearance=RtffM86J.2AMKNqMKcF5WTGWOK11V7gklzY2rDRNu24-1701826018-0-1-d71c894c.1d67b4d8.801dd6ac-0.2.1701826018"
headers["cookie"] = cookie
url = url + "/torrents.php"
html = ""
# for _ in range(5):
# try:
# response = requests.get(url, headers=headers, timeout=5 * 60)
# if response.status_code == 200:
# html = response.text
# break
# else:
# print(f"{section_name} , 出现错误code码是{response.status_code}, {response.text}")
# break
# except Exception as e:
# time.sleep(2)
# else:
# print(f"{section_name} , 5次出现错误无法访问")
# with open('test.html', 'r', encoding='utf-8') as file:
# html = file.read()
# print(html)
# doc_html = lhtml.fromstring(html)
# page_href = doc_html.xpath('//td[@class="embedded"]//p[@align="center"][1]//a[last()]/@href')[0]
# pages_str = extract_id(page_href, "page")
# pages = int(pages_str) if pages_str.isdigit() else 0
# for i in range(0, pages):
# print(i)
# 查询数据库表的结构信息
columns = PtWebsiteData.__table__.columns.keys()
# 使用列名创建一个包含空值的字典
data = {col: [] for col in columns}
# 创建空 DataFrame
df = pd.DataFrame(data)
db_main = SqliteDbMain(config.pt_website_db)
count = db_main.pandas_query_by_condition(
model=func.count(PtWebsiteData.id),
query_condition=PtWebsiteData.source_name == "1PTBar/壹PT",
)
print(int(count['count_1'].iloc[0]))
"""
主键id,pt资源id,来源名称,一级标题,二级标题,分类id分类名称
种子状态,状态剩余时间,做种状态,评论数,资源上传时间,资源大小
做种数,下载数,完成数发布者豆瓣评分IMDB评分下载链接详情链接
CREATE TABLE IF NOT EXISTS pt_website_data (
id INTEGER PRIMARY KEY,
pt_id INTEGER,
source_name TEXT NOT NULL,
first_title TEXT NOT NULL,
second_title TEXT NOT NULL,
type_id INTEGER,
type_name TEXT,
seed_status TEXT,
status_remaining_time TEXT,
seeding_status TEXT,
comment_count INTEGER,
upload_time TEXT,
size TEXT,
seed_count INTEGER,
download_count INTEGER,
completion_count INTEGER,
publisher TEXT,
douban_rating REAL,
imdb_rating REAL,
download_link TEXT,
details_link TEXT,
UNIQUE(pt_id , source_name)
);
CREATE TABLE IF NOT EXISTS pt_website_type (
id INTEGER PRIMARY KEY,
source_name TEXT NOT NULL,
type_name TEXT NOT NULL,
type_url TEXT NOT NULL
);
"""

0
junit/__init__.py Normal file
View File

View File

@ -0,0 +1,27 @@
import toml
from PT.pt_operation import PtOperation
def attendances_junit(name):
with open('../PT/pt_config.toml', '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')}")
if name == section_name:
PtOperation().attendances(section_name, section_data)
def signup_junit(name):
with open('../PT/pt_config.toml', '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')}")
if name == section_name:
PtOperation().signup(section_name, section_data)
# attendances_junit("icc2022")
signup_junit("1PTBar/壹PT")