diff --git a/spider/task.py b/spider/task.py index 520334a..cc113ee 100644 --- a/spider/task.py +++ b/spider/task.py @@ -604,9 +604,19 @@ def playwright_comment(cookies, target_url, content, image_key=None): with sync_playwright() as playwright: update_windows_distinguish() + username = 'moremore_51WM1' + password = 'TOv5y0nXCZH_JH+5' + country = 'US' + browser = playwright.chromium.launch( - headless=False, args=['--start-maximized'], executable_path=path + headless=False, args=['--start-maximized'], executable_path=path, + proxy={ + "server": "http://pr.oxylabs.io:7777", # 必填 + "username": f"customer-{username}-cc-{country}", + "password": password + } ) + context = browser.new_context(no_viewport=True) context.add_cookies(parse_cookies(cookies)) page = context.new_page() @@ -621,7 +631,7 @@ def playwright_comment(cookies, target_url, content, image_key=None): # 文字或图片类型 input_xpath = '//div[@role="dialog"]//span[text()="Comment" or@data-ad-rendering-role="comment_button"]' attach_xpath = '//div[@id="focused-state-actions-list"]//div[@aria-label="Attach a photo or video"]' - comment_xpath = '//div[@aria-label="Comment"]' + comment_xpath = '//div[@id="focused-state-composer-submit"]' page.click(input_xpath) sleep(1, 2) elif 'watch/?v' in target_url or '/videos/' in target_url: