fix(weibo): 识别支付页拒绝并保护有效 CK 状态
This commit is contained in:
@@ -277,6 +277,7 @@ class WeiboClient:
|
||||
self.cookie = normalize_weibo_cookie(cookie) if cookie else ""
|
||||
self.timeout = timeout
|
||||
self.session = session or requests.Session()
|
||||
self._last_text_url = ""
|
||||
self.session.headers.update(
|
||||
{
|
||||
"User-Agent": WEIBO_MOBILE_UA,
|
||||
@@ -336,6 +337,7 @@ class WeiboClient:
|
||||
timeout=self.timeout,
|
||||
)
|
||||
response.raise_for_status()
|
||||
self._last_text_url = str(getattr(response, "url", "") or url)
|
||||
return response.text
|
||||
except requests.RequestException as exc:
|
||||
raise WeiboTransportError(f"请求微博收银台失败: {exc}") from exc
|
||||
@@ -821,6 +823,12 @@ class WeiboClient:
|
||||
"Referer": "https://vipclub.weibo.com/",
|
||||
},
|
||||
)
|
||||
if urlsplit(self._last_text_url).path.rstrip("/") == "/sorry":
|
||||
raise WeiboRechargeError(
|
||||
"微博支付页拒绝了当前账号(跳转 /sorry)。"
|
||||
"CK 首页仍有效,请重新登录微博更新 CK,"
|
||||
"或确认该账号具备支付/助威资格"
|
||||
)
|
||||
parser = _CashierParser()
|
||||
parser.feed(html)
|
||||
if not parser.pay_id:
|
||||
|
||||
Reference in New Issue
Block a user