修复评论发送按钮位置变更, 增加评论代理

This commit is contained in:
work
2026-04-09 08:32:16 +08:00
parent 97c877f27c
commit ac4a6c394b

View File

@@ -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: