更改显示比例增加发视频等待时间

This commit is contained in:
work
2025-08-21 09:35:24 +08:00
parent ad81130aa4
commit e9e03cd7ca
2 changed files with 7 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import os import os
BASE_PATH = os.path.dirname(__file__) BASE_PATH = os.path.dirname(__file__)
SAFE = '!' SAFE = '!'
MIMETYPE = { MIMETYPE = {
@@ -11,7 +12,6 @@ MIMETYPE = {
PIC_TYPE = ('image/jpeg', 'image/png') PIC_TYPE = ('image/jpeg', 'image/png')
ELEMENT = { ELEMENT = {
} }
@@ -26,6 +26,8 @@ PROXY_HOST = 'http://proxy.ipipgo.com:31212'
PROXY_USER = 'customer-94620c-country-US' PROXY_USER = 'customer-94620c-country-US'
PROXY_PASS = '4ea715cd' PROXY_PASS = '4ea715cd'
api_key = "adf0d1fc9c9313b7f87c18bf9caef01d" api_key = "adf0d1fc9c9313b7f87c18bf9caef01d"
api_url = "http://local.adspower.net:50325" api_url = "http://local.adspower.net:50325"
# 显示缩放比例 1为100%
DISPLAY_SCALE = 0.7

View File

@@ -270,6 +270,7 @@ def retry_get_new_video(page, cookies, video_count):
page.query_selector_all('//img[@alt="View photo"]')[0].hover() page.query_selector_all('//img[@alt="View photo"]')[0].hover()
page.query_selector_all('//img[@alt="View photo"]')[0].click() page.query_selector_all('//img[@alt="View photo"]')[0].click()
page.reload() page.reload()
time.sleep(random.randint(3, 5))
return page.url return page.url
# 计算下一次重试时间 # 计算下一次重试时间
@@ -296,6 +297,7 @@ def playwright_post(cookies, content, image_key=None):
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))
page = context.new_page() page = context.new_page()
page.evaluate(f'document.body.style.zoom = "{const.DISPLAY_SCALE}"')
check_account_status(page, parse_cookies(cookies)) check_account_status(page, parse_cookies(cookies))
# 声明默认发布视频数量 # 声明默认发布视频数量
@@ -335,6 +337,7 @@ def playwright_post(cookies, content, image_key=None):
# 视频格式要单独去获取链接 # 视频格式要单独去获取链接
if ".mp4" in image_key: if ".mp4" in image_key:
post_url = retry_get_new_video(page, cookies, video_count) post_url = retry_get_new_video(page, cookies, video_count)
time.sleep(random.randint(3, 10))
except Error as e: except Error as e:
raise OperationFailed(f'操作超时,请重试{e}') raise OperationFailed(f'操作超时,请重试{e}')