From 7fef29dd0af80854f9186332683a8e530569e5b2 Mon Sep 17 00:00:00 2001 From: theluyuan <1162963624@qq.com> Date: Sat, 21 Feb 2026 20:03:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=AF=8F30=E5=88=86=E9=92=9F=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E6=89=A7=E8=A1=8C=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- main.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index cdd8186..232fbd1 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,10 @@ """ 使用 Nodriver 访问 Cloudflare 保护的 audiences.me/torrents.php, 启动时从根目录 cookies.txt 加载 Cookie,采用等待自动通过 + 选择器点击 Turnstile 过验证。 +每 30 分钟执行一次检查。 """ +import asyncio import nodriver as uc from cookies_loader import ( get_cookies_path, @@ -70,7 +72,11 @@ async def try_click_cf_turnstile(page): pass -async def main(): +INTERVAL_MINUTES = 30 + + +async def run_one_check(): + """执行一次检查:打开浏览器、过 CF 验证,完成后关闭浏览器。""" # 建议非无头模式以提高 CF 通过率 browser = await uc.start(headless=False) path = get_cookies_path() @@ -93,7 +99,7 @@ async def main(): await page.sleep(2) val = await get_search_btn_value(page) if val == "给我搜": - # 不需要验证,直接结束 + # 不需要验证,直接结束本次检查 await browser.stop() return @@ -106,7 +112,7 @@ async def main(): await page.sleep(10) val_after = await get_search_btn_value(page) if val_after == "给我搜": - # 已通过,关闭程序 + # 已通过,关闭浏览器,结束本次检查 await browser.stop() return @@ -114,5 +120,12 @@ async def main(): page = await browser.get(TARGET_URL) +async def main(): + """每 30 分钟执行一次检查,循环运行。""" + while True: + await run_one_check() + await asyncio.sleep(INTERVAL_MINUTES * 60) + + if __name__ == "__main__": uc.loop().run_until_complete(main())