|
|
|
@ -70,7 +70,7 @@ async def run(playwright: Playwright):
@@ -70,7 +70,7 @@ async def run(playwright: Playwright):
|
|
|
|
|
# 點擊每個連結 |
|
|
|
|
for i in range(iLink_count): |
|
|
|
|
iRetry_count = 0 # 设置重试次数计数器 |
|
|
|
|
while iRetry_count < 3: # 假设最多重试3次 |
|
|
|
|
while iRetry_count < 5: # 假设最多重试3次 |
|
|
|
|
|
|
|
|
|
# 使用 nth(i) 定位第 i 個元素,並點擊 |
|
|
|
|
try: |
|
|
|
@ -301,11 +301,11 @@ async def run(playwright: Playwright):
@@ -301,11 +301,11 @@ async def run(playwright: Playwright):
|
|
|
|
|
|
|
|
|
|
break |
|
|
|
|
except Exception as e: # 捕获可能发生的异常 |
|
|
|
|
print(f"遇到错误:{e},尝试返回并重试") |
|
|
|
|
print(f"遇到錯誤:{e},嘗試返回並重試") |
|
|
|
|
await oPage.go_back() # 返回前一页 |
|
|
|
|
iRetry_count += 1 # 重试计数器加1 |
|
|
|
|
if iRetry_count >= 3: |
|
|
|
|
print("重试次数超限,跳过当前链接") |
|
|
|
|
if iRetry_count >= 5: |
|
|
|
|
print("重試次數超過,跳過當前連結") |
|
|
|
|
break # 跳出循环,处理下一个链接 |
|
|
|
|
# 使用浏览器的后退功能返回列表页,这样不需要重新加载初始URL |
|
|
|
|
await oPage.go_back() |
|
|
|
|