feat(纯算): 增加 captcha 域 cookie 透传 + H3 单变量实验脚本
做了什么: - TencentCaptchaClient 新增可选 cookies 参数, 逐条写入 captcha 域 Cookie 头 (默认 None, 行为不变) - OneMsAdapter 新增 captcha_cookies 透传 - 新增 scripts/experiment_h3_cookie_ab.py: 只改 cookie 一个变量做 A/B 对照并自动判读 为什么: - 账本 §7.5 的 H3 (腾讯云登录 cookie uin/skey/qcmainCSRFToken/intl) 是唯一 尚未单变量验证过的差异; 其余 (环境 / 后端 / 出口 IP / 静默时长) 均已排除 怎么验证: - 离线: 带 cookie 时请求头为 Cookie=uin=..;intl=1, 不带时为 None (默认行为不变) - .venv/bin/python -m tcaptcha.selftest 全绿 (crypto_core + glyph 8/8 + xtea_key)
This commit is contained in:
@@ -55,13 +55,16 @@ class OneMsAdapter:
|
||||
|
||||
def __init__(self, cookie: Optional[str] = None, user_agent: str = DEFAULT_USER_AGENT,
|
||||
timeout: float = 15.0, proxy: Optional[str] = None,
|
||||
proxy_api: Optional[str] = None, telemetry_mode: str = "python_keyed"):
|
||||
proxy_api: Optional[str] = None, telemetry_mode: str = "python_keyed",
|
||||
captcha_cookies: Optional[Dict[str, str]] = None):
|
||||
self.user_agent = user_agent
|
||||
self.timeout = timeout
|
||||
# 出口代理 (可选)。注意: 实测换出口 IP 并不能解决 errorCode=12 (见 ANALYSIS.md §7)
|
||||
self.proxy = proxy
|
||||
self.proxy_api = proxy_api
|
||||
self.telemetry_mode = telemetry_mode
|
||||
# 可选: 透传到 captcha 域的腾讯云登录 cookie (账本 §7.5 的 H3 实验入口)
|
||||
self.captcha_cookies = captcha_cookies
|
||||
headers = {
|
||||
"User-Agent": user_agent,
|
||||
"Origin": ONE_MS_BASE,
|
||||
@@ -130,6 +133,7 @@ class OneMsAdapter:
|
||||
accept_kinds=(KIND_TEXT_CLICK,),
|
||||
proxy=proxy,
|
||||
telemetry_mode=self.telemetry_mode,
|
||||
cookies=self.captcha_cookies,
|
||||
)
|
||||
connectivity_error = False
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user