加入错误重试机制

This commit is contained in:
晓丰 2025-07-18 00:20:32 +08:00
parent 728cf5a44f
commit 6e6ab61998

View File

@ -305,12 +305,28 @@ class DailymotionClient:
@require_login @require_login
def report_follow_up(self, report_id: str): def report_follow_up(self, report_id: str):
txt = "I am the authorized agent of Beijing iQIYI Technology Co., Ltd., responsible for dealing with unauthorized overseas distribution of pirated videos of our works.We have confirmed that the above links contain infringing content and we insist on requesting to takedown. Thank you!" max_retries = 3 # 最大重试次数
self.page.goto("https://faq.dailymotion.com/hc/en-us/requests/{}".format(report_id), timeout=30000) retry_delay = 2 # 重试间隔(秒)
loaded = False
subsequent_status = ""
# 重试页面加载和状态检测
for attempt in range(max_retries):
try:
self.page.goto(f"https://faq.dailymotion.com/hc/en-us/requests/{report_id}", timeout=30000)
self.page.wait_for_selector("span.status-label", timeout=30000) self.page.wait_for_selector("span.status-label", timeout=30000)
status_raw = self.page.locator("span.status-label").text_content() status_raw = self.page.locator("span.status-label").text_content()
subsequent_status = status_raw.strip().lower() if status_raw else None subsequent_status = status_raw.strip().lower() if status_raw else None
loaded = True
break # 成功则跳出循环
except Exception as e:
print(f"尝试 {attempt + 1}/{max_retries} 失败: {str(e)}")
if attempt < max_retries - 1:
time.sleep(retry_delay)
if not loaded:
return 1, "页面加载失败"
txt = "I am the authorized agent of Beijing iQIYI Technology Co., Ltd., responsible for dealing with unauthorized overseas distribution of pirated videos of our works.We have confirmed that the above links contain infringing content and we insist on requesting to takedown. Thank you!"
if "awaiting your reply" in subsequent_status: if "awaiting your reply" in subsequent_status:
span_show = self.page.locator('span.comment-show-container-content') span_show = self.page.locator('span.comment-show-container-content')
if span_show.count() > 0: if span_show.count() > 0: