fix: 售罄临时页仅下拉刷新一次 (#265)
This commit is contained in:
@@ -24,6 +24,7 @@ from .pdd_device_service import (
|
||||
PddDeviceService,
|
||||
current_thread_device_service,
|
||||
)
|
||||
from .pdd_goods_refresh import pull_down_to_refresh
|
||||
from .performance_timing import current_performance_trace
|
||||
from .pdd_collect_service import (
|
||||
PddCollectError,
|
||||
@@ -32,7 +33,9 @@ from .pdd_collect_service import (
|
||||
)
|
||||
from .pdd_page_classifier import (
|
||||
ACTION_NETWORK_ERROR,
|
||||
ACTION_OUT_OF_STOCK,
|
||||
ACTION_READY,
|
||||
ACTION_REFRESH,
|
||||
ACTION_REOPEN,
|
||||
ACTION_UNAVAILABLE,
|
||||
PAGE_CAPTCHA,
|
||||
@@ -1601,6 +1604,32 @@ class U2PddPurchaseAdapter(PddPurchaseAdapter):
|
||||
if trace is not None:
|
||||
trace.checkpoint("end_to_end_total")
|
||||
return xml_data
|
||||
if decision.action == ACTION_REFRESH:
|
||||
try:
|
||||
pull_down_to_refresh(device, root)
|
||||
except Exception as exc:
|
||||
raise PddPurchaseError(
|
||||
"PDD_PAGE_REFRESH_FAILED",
|
||||
f"商品售罄临时页无法安全下拉刷新:{exc}",
|
||||
step="purchase_open_goods",
|
||||
retryable=True,
|
||||
diagnostics={"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 PddPurchaseError(
|
||||
"PDD_GOODS_UNAVAILABLE",
|
||||
"商品下拉刷新后仍显示已售罄",
|
||||
step="purchase_open_goods",
|
||||
retryable=False,
|
||||
diagnostics={
|
||||
"page_reason": "out_of_stock",
|
||||
"refresh_attempts": 1,
|
||||
},
|
||||
)
|
||||
if decision.action == ACTION_REOPEN:
|
||||
with (
|
||||
trace.stage("open_url_retry")
|
||||
|
||||
Reference in New Issue
Block a user