INNER CODE UNIT · Python

_fetch_user_agent

1837620622/cloudflare-bypass-2026 · bypass_nodriver.py:168

async def _fetch_user_agent(tab) -> str:
    """获取 navigator.userAgent"""
    try:
        if hasattr(tab, "evaluate"):
            ua = await tab.evaluate("navigator.userAgent")
            if isinstance(ua, str) and ua:
                return ua
    except Exception:
        pass
    try:
        ua_result = await tab.send(
            uc.cdp.runtime.evaluate(expression="navigator.userAgent", return_by_value=True)
        )
        # 兼容对象 / dict 两种返回
        if isinstance(ua_result, dict):
            result_obj = ua_result.get("result") or ua_result
            if isinstance(result_obj, dict):
                return str(result_obj.get("value") or "")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…