正式使用代理进行评论, 点赞, 转发功能(发帖可能会有视频太大了暂时不用代理)
This commit is contained in:
@@ -36,7 +36,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
machine:
|
machine:
|
||||||
- windows-101.36.102.136
|
- windows-101.36.102.136
|
||||||
# - windows-101.36.104.175
|
- windows-101.36.104.175
|
||||||
steps:
|
steps:
|
||||||
- name: 更新或clone项目
|
- name: 更新或clone项目
|
||||||
shell: powershell
|
shell: powershell
|
||||||
|
|||||||
@@ -202,8 +202,14 @@ def playwright_like(cookies, target_url):
|
|||||||
with lock:
|
with lock:
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
update_windows_distinguish()
|
update_windows_distinguish()
|
||||||
|
|
||||||
|
proxy_url = get_proxy_from_api()
|
||||||
|
logger.info(f"使用proxi={proxy_url}")
|
||||||
|
|
||||||
browser = playwright.chromium.launch(
|
browser = playwright.chromium.launch(
|
||||||
headless=False, args=['--start-maximized'], executable_path=path
|
headless=False, args=['--start-maximized'], executable_path=path, proxy={
|
||||||
|
"server": proxy_url,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
context = browser.new_context(no_viewport=True)
|
context = browser.new_context(no_viewport=True)
|
||||||
context.add_cookies(parse_cookies(cookies))
|
context.add_cookies(parse_cookies(cookies))
|
||||||
@@ -402,8 +408,14 @@ def playwright_comment(cookies, target_url, content, image_key=None):
|
|||||||
with lock:
|
with lock:
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
update_windows_distinguish()
|
update_windows_distinguish()
|
||||||
|
|
||||||
|
proxy_url = get_proxy_from_api()
|
||||||
|
logger.info(f"使用proxi={proxy_url}")
|
||||||
|
|
||||||
browser = playwright.chromium.launch(
|
browser = playwright.chromium.launch(
|
||||||
headless=False, args=['--start-maximized'], executable_path=path
|
headless=False, args=['--start-maximized'], executable_path=path, proxy={
|
||||||
|
"server": proxy_url,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
context = browser.new_context(no_viewport=True)
|
context = browser.new_context(no_viewport=True)
|
||||||
context.add_cookies(parse_cookies(cookies))
|
context.add_cookies(parse_cookies(cookies))
|
||||||
@@ -761,6 +773,8 @@ def playwright_login(username, password, code_2fa=None):
|
|||||||
|
|
||||||
def get_proxy_from_api():
|
def get_proxy_from_api():
|
||||||
"""从代理API获取代理地址"""
|
"""从代理API获取代理地址"""
|
||||||
|
if os.getenv("dev") is not None:
|
||||||
|
return f"http://192.168.1.69:1080"
|
||||||
try:
|
try:
|
||||||
# 假设你的代理API地址
|
# 假设你的代理API地址
|
||||||
proxy_api_url = const.PROXY_HOST
|
proxy_api_url = const.PROXY_HOST
|
||||||
@@ -893,8 +907,14 @@ def playwright_share(cookies, target_url, content):
|
|||||||
with lock:
|
with lock:
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
update_windows_distinguish()
|
update_windows_distinguish()
|
||||||
|
|
||||||
|
proxy_url = get_proxy_from_api()
|
||||||
|
logger.info(f"使用proxi={proxy_url}")
|
||||||
|
|
||||||
browser = playwright.chromium.launch(
|
browser = playwright.chromium.launch(
|
||||||
headless=False, args=['--start-maximized'], executable_path=path
|
headless=False, args=['--start-maximized'], executable_path=path, proxy={
|
||||||
|
"server": proxy_url,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
context = browser.new_context(no_viewport=True)
|
context = browser.new_context(no_viewport=True)
|
||||||
context.add_cookies(parse_cookies(cookies))
|
context.add_cookies(parse_cookies(cookies))
|
||||||
|
|||||||
Reference in New Issue
Block a user