fix: 修改初始化参数以支持非无头模式并更新用户界面文本
This commit is contained in:
parent
52e2139ff4
commit
2cd31e4a74
@ -87,7 +87,7 @@ class DailymotionClient:
|
|||||||
EMAIL = "copyright@qiyi.com"
|
EMAIL = "copyright@qiyi.com"
|
||||||
PASSWORD = "ppsIQIYI2018@"
|
PASSWORD = "ppsIQIYI2018@"
|
||||||
|
|
||||||
def __init__(self, headless: bool = True):
|
def __init__(self, headless: bool = False):
|
||||||
self.email = self.EMAIL
|
self.email = self.EMAIL
|
||||||
self.password = self.PASSWORD
|
self.password = self.PASSWORD
|
||||||
self.headless = headless
|
self.headless = headless
|
||||||
@ -95,9 +95,20 @@ class DailymotionClient:
|
|||||||
|
|
||||||
self._pw = sync_playwright().start()
|
self._pw = sync_playwright().start()
|
||||||
self.browser: Browser = self._pw.chromium.launch(
|
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_ts = 0
|
||||||
self._last_check_result = False
|
self._last_check_result = False
|
||||||
@ -120,7 +131,7 @@ class DailymotionClient:
|
|||||||
self.page.wait_for_selector("//input[@data-testid=\"emailInput\"]")
|
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:
|
if i_now_btn.count() > 0:
|
||||||
i_now_btn.click()
|
i_now_btn.click()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user