fix(xhs): 登录二维码流程改用非无头浏览器绕过IP风控

XHS对未登录的无头浏览器请求触发风控(code 300012: IP存在风险),
重定向到安全限制页导致二维码选择器永远匹配不到。

- getLoginQRCode 单独启动 headless:false 浏览器,登录弹框可正常加载
- 扫码成功后直接从登录 context 提取 storageState 保存到磁盘
- 调用 browser.clearContext() 让主 BrowserManager 下次重新加载新 cookies
- waitForLoginAndRelease 改为接收 BrowserContext 并关闭登录浏览器
- 修正 qrCodeImage 选择器:'.login-container .qrcode-img' → 'img.qrcode-img'
This commit is contained in:
2026-03-01 17:59:39 +08:00
parent 838b244929
commit 8b39520ec7
2 changed files with 83 additions and 29 deletions
+2 -2
View File
@@ -4,8 +4,8 @@
export const XHS_SELECTORS = {
login: {
/** QR code image on the login modal / page. */
qrCodeImage: '.login-container .qrcode-img',
/** QR code image on the login modal (auto-appears after a few seconds). */
qrCodeImage: 'img.qrcode-img',
/** Element present only when the user is logged in (sidebar channel link). */
loggedInIndicator: '.user .link-wrapper .channel',
/** The "login" button that opens the QR code modal (if not already shown). */