fix: 售罄临时页仅下拉刷新一次 (#265)

This commit is contained in:
chengma
2026-08-18 11:58:23 +08:00
parent fc13b2c7a3
commit e7ac5a470f
8 changed files with 304 additions and 0 deletions
+25
View File
@@ -20,10 +20,13 @@ from typing import Any, Callable, Iterable, Mapping, Optional, Sequence
from urllib.parse import parse_qs, urlparse
from .pdd_device_service import PDD_PACKAGE_NAME, PddDeviceError, PddDeviceService
from .pdd_goods_refresh import pull_down_to_refresh
from .performance_timing import current_performance_trace
from .pdd_page_classifier import (
ACTION_NETWORK_ERROR,
ACTION_OUT_OF_STOCK,
ACTION_READY,
ACTION_REFRESH,
ACTION_REOPEN,
ACTION_UNAVAILABLE,
PAGE_CAPTCHA,
@@ -1276,6 +1279,28 @@ class PddCollectService:
if trace is not None:
trace.checkpoint("end_to_end_total")
return
if decision.action == ACTION_REFRESH:
try:
pull_down_to_refresh(device, root)
except Exception as exc:
raise PddCollectError(
"PDD_PAGE_REFRESH_FAILED",
f"商品售罄临时页无法安全下拉刷新:{exc}",
{"page_reason": "out_of_stock"},
) from exc
tracker.refreshed_out_of_stock(self._monotonic())
self._sleep(0.5)
last_recorded = ""
continue
if decision.action == ACTION_OUT_OF_STOCK:
raise PddCollectError(
"PDD_GOODS_UNAVAILABLE",
"商品下拉刷新后仍显示已售罄",
{
"page_reason": "out_of_stock",
"refresh_attempts": 1,
},
)
if decision.action == ACTION_REOPEN:
with (
trace.stage("open_url_retry")