From 1e35b061c97ad1f431630d3ecfdb5459cb552349 Mon Sep 17 00:00:00 2001 From: "pookz@stme" Date: Tue, 3 Sep 2024 17:39:59 +0800 Subject: [PATCH] =?UTF-8?q?1.=20douyin=20=E4=B8=8A=E4=BC=A0=E5=B0=81?= =?UTF-8?q?=E9=9D=A2=E9=83=A8=E5=88=86=E6=9B=B4=E7=A8=B3=E5=AE=9A=202.=20?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E4=B8=8D=E7=9F=A5=E9=81=93=E4=B8=BA=E4=BD=95?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=A5=87=E6=80=AA=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=EF=BC=8C=E6=9A=82=E6=97=B6=E5=85=88=E4=B8=8D=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uploader/douyin_uploader/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uploader/douyin_uploader/main.py b/uploader/douyin_uploader/main.py index 28e9134..50cf7a1 100644 --- a/uploader/douyin_uploader/main.py +++ b/uploader/douyin_uploader/main.py @@ -19,6 +19,13 @@ async def cookie_auth(account_file): page = await context.new_page() # 访问指定的 URL 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) + except: + print("[+] 等待5秒 cookie 失效") + await context.close() + await browser.close() + return False # 2024.06.17 抖音创作者中心改版 if await page.get_by_text('手机号登录').count(): print("[+] 等待5秒 cookie 失效") @@ -203,6 +210,7 @@ class DouYinVideo(object): async def set_thumbnail(self, page: Page, thumbnail_path: str): if thumbnail_path: await page.click('text="选择封面"') + await page.wait_for_selector("div.semi-modal-content:visible") await page.click('text="上传封面"') # 定位到上传区域并点击 await page.locator("div[class^='semi-upload upload'] >> input.semi-upload-hidden-input").set_input_files(thumbnail_path) @@ -210,6 +218,9 @@ class DouYinVideo(object): await page.locator("div[class^='uploadCrop'] button:has-text('完成')").click() async def set_location(self, page: Page, location: str = "杭州市"): + # todo supoort location later + # await page.get_by_text('添加标签').locator("..").locator("..").locator("xpath=following-sibling::div").locator( + # "div.semi-select-single").nth(0).click() await page.locator('div.semi-select span:has-text("输入地理位置")').click() await page.keyboard.press("Backspace") await page.wait_for_timeout(2000)