修复抖音cookie有效性判定

This commit is contained in:
陶欣
2025-08-25 17:06:54 +08:00
committed by GitHub
parent ac80cd2ddd
commit 74939a0c06
+12 -9
View File
@@ -22,18 +22,21 @@ async def cookie_auth_douyin(account_file):
await page.goto("https://creator.douyin.com/creator-micro/content/upload")
try:
await page.wait_for_url("https://creator.douyin.com/creator-micro/content/upload", timeout=5000)
# 2024.06.17 抖音创作者中心改版
# 判断
# 等待“扫码登录”元素出现,超时 5 秒(如果 5 秒没出现,说明 cookie 有效)
try:
await page.get_by_text("扫码登录").wait_for(timeout=5000)
logger.error("[+] cookie 失效,需要扫码登录")
return False
except:
logger.success("[+] cookie 有效")
return True
except:
print("[+] 等待5秒 cookie 失效")
logger.error("[+] 等待5秒 cookie 失效")
await context.close()
await browser.close()
return False
# 2024.06.17 抖音创作者中心改版
if await page.get_by_text('手机号登录').count() or await page.get_by_text('扫码登录').count():
print("[+] 等待5秒 cookie 失效")
return False
else:
print("[+] cookie 有效")
return True
async def cookie_auth_tencent(account_file):
async with async_playwright() as playwright:
@@ -114,4 +117,4 @@ async def check_cookie(type,file_path):
return False
# a = asyncio.run(check_cookie(1,"3a6cfdc0-3d51-11f0-8507-44e51723d63c.json"))
# print(a)
# print(a)