从 UA 选择可用的 curl_cffi 浏览器指纹版本。
(user_agent: str)
| 219 | |
| 220 | |
| 221 | def _guess_impersonate_from_user_agent(user_agent: str) -> str: |
| 222 | """从 UA 选择可用的 curl_cffi 浏览器指纹版本。""" |
| 223 | ua = (user_agent or "").strip() |
| 224 | major_match = re.search(r"(?:Chrome|Chromium|Edg|EdgA|EdgiOS)/(\d+)", ua) |
| 225 | if not major_match: |
| 226 | return "chrome120" |
| 227 | |
| 228 | try: |
| 229 | major = int(major_match.group(1)) |
| 230 | except Exception: |
| 231 | return "chrome120" |
| 232 | |
| 233 | if major >= 124: |
| 234 | return "chrome124" |
| 235 | if major >= 120: |
| 236 | return "chrome120" |
| 237 | return "chrome120" |
| 238 | |
| 239 | |
| 240 | def _build_proxy_map(proxy_url: str) -> Optional[Dict[str, str]]: |
no outgoing calls