From 200eef7dcd653a1a84f710fc479aa56891d8340f Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 20 Aug 2025 21:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=91=E5=B8=96=E5=B8=A6?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spider/task.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spider/task.py b/spider/task.py index d9d33ff..cd89ae8 100644 --- a/spider/task.py +++ b/spider/task.py @@ -255,22 +255,20 @@ def playwright_post(cookies, content, image_key=None): filename = image_key.split('/')[-1] file_path = os.path.join(BASE_PATH, 'files', filename) client.fget_object(BUCKET, image_key, file_path) - page.click('//span[text()="Photo/video"]') + sleep(1, 2) - with page.expect_file_chooser() as fc_info: - page.click('//span[text()="Add photos/videos"]') - file_chooser = fc_info.value - file_chooser.set_files(file_path) + page.locator('input[accept="image/*,image/heif,image/heic,video/*,video/mp4,video/x-m4v,' + 'video/x-matroska,.mkv"]').set_input_files(file_path) time.sleep(5) if not image_key: page.click('''//span[contains(text(), "What's on your mind")]''') _edit_privacy(page) page.type('''//div[contains(@aria-placeholder, "What's on your mind")]''', content, delay=50) - page.click('//div[@aria-label="Post"]') + page.click('//div[@aria-label="Post"]', timeout=300000) time.sleep(15) post_index = page.locator('//div[@aria-posinset="1"]//a[@role="link"]').nth(2) - post_index.click() + post_index.click(timeout=600000) time.sleep(5) page.reload() post_url = page.url