From 2cd31e4a747ad90a462c7befc6f6c419e60f6e6b Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Wed, 4 Jun 2025 22:25:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=8F=82=E6=95=B0=E4=BB=A5=E6=94=AF=E6=8C=81=E9=9D=9E?= =?UTF-8?q?=E6=97=A0=E5=A4=B4=E6=A8=A1=E5=BC=8F=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=95=8C=E9=9D=A2=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report_video.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/report_video.py b/report_video.py index 6d1b844..fd18b4c 100644 --- a/report_video.py +++ b/report_video.py @@ -87,7 +87,7 @@ class DailymotionClient: EMAIL = "copyright@qiyi.com" PASSWORD = "ppsIQIYI2018@" - def __init__(self, headless: bool = True): + def __init__(self, headless: bool = False): self.email = self.EMAIL self.password = self.PASSWORD self.headless = headless @@ -95,9 +95,20 @@ class DailymotionClient: self._pw = sync_playwright().start() self.browser: Browser = self._pw.chromium.launch( - headless=self.headless + headless=self.headless, + # proxy={'server':'http://127.0.0.1:7890'} ) - self.page: Page = self.browser.new_page() + self.context = self.browser.new_context( + user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/122.0.0.0 Safari/537.36", + locale="en-US", + viewport={"width": 1280, "height": 800}, + timezone_id="Asia/Shanghai", + permissions=[], + ) + self.context.add_init_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") + self.page: Page = self.context.new_page() self._last_check_ts = 0 self._last_check_result = False @@ -120,7 +131,7 @@ class DailymotionClient: self.page.wait_for_selector("//input[@data-testid=\"emailInput\"]") # “我了解”弹窗 - i_now_btn = self.page.locator("button:has-text(\"我了解\")") + i_now_btn = self.page.locator("button:has-text(\"I understand\")") if i_now_btn.count() > 0: i_now_btn.click()