[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-post-cn-nodriver-pachong-daili-shizhan":3},{"success":4,"payload":5,"related":67,"errors":161},true,{"id":6,"slug":7,"title":8,"excerpt":9,"body_html":10,"meta_title":11,"meta_description":12,"canonical_url":13,"canonical_override":14,"og_title":15,"og_description":16,"og_image_url":17,"faq_json":18,"key_takeaways":28,"allow_index":34,"noindex_google_only":4,"allow_follow":4,"published_at":35,"updated_at":35,"content_updated_at":36,"featured_image_url":37,"featured_image_alt":38,"card_image_url":39,"reading_time_minutes":40,"author":41,"categories":45,"tags":52,"alternates":53,"locale_paths":60,"views":66},138,"nodriver-pachong-daili-shizhan","使用 nodriver 爬取完整指南：异步 CDP 浏览器与住宅代理实战","深入讲解 nodriver 架构、惯用异步 API、CDP 代理认证配置，以及如何结合 ProxyHat 住宅代理实现大规模隐身爬取。涵盖并发 Tab 扩展、Docker 集群部署和 curl_cffi 替代方案。","\u003Cp>如果你正在用 Python 做大规模网页爬取，很可能遇到过 Cloudflare 或 Imperva 的 \"Just a moment...\" 挑战页面。传统 Selenium 方案在 2024 年后越来越容易被识别。使用 nodriver 爬取是 undetected-chromedriver 作者 ultrafunkamsterdam 推出的下一代方案——完全异步、直连 Chrome DevTools Protocol (CDP)，不依赖 Selenium WebDriver。本文将深入讲解 nodriver 的架构、惯用 API、nodriver 代理配置，以及如何结合 ProxyHat 住宅代理实现大规模隐身爬取。\u003C\u002Fp>\n\u003Cblockquote>\u003Cp>\u003Cstrong>法律与合规提示：\u003C\u002Fstrong>本文技术仅适用于授权自动化和公开数据采集。未经授权访问受保护系统可能违反美国 \u003Ca href=\"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FComputer_Fraud_and_Abuse_Act\" rel=\"noopener noreferrer\">《计算机欺诈和滥用法》(CFAA)\u003C\u002Fa> 或欧盟 \u003Ca href=\"https:\u002F\u002Fgdpr.eu\u002F\" rel=\"noopener noreferrer\">GDPR\u003C\u002Fa>。请遵守目标网站的 robots.txt 和服务条款。\u003C\u002Fp>\u003C\u002Fblockquote>\n\u003Ch2>nodriver 架构：为什么使用 nodriver 爬取更隐蔽\u003C\u002Fh2>\n\u003Cp>要理解 nodriver 的优势，需要先了解传统方案的缺陷。Selenium WebDriver 通过 HTTP 协议与浏览器通信，会在页面中注入 \u003Ccode>navigator.webdriver=true\u003C\u002Fcode> 标志，并留下多个 CDP 检测特征。Cloudflare 和 Imperva 等反爬服务正是利用这些特征来识别自动化流量。\u003C\u002Fp>\n\u003Cp>nodriver 采用了完全不同的架构：\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>零 WebDriver 依赖：\u003C\u002Fstrong>直接通过 WebSocket 连接 Chrome 的 CDP 端点，不启动 chromedriver 进程，不注入 WebDriver 标志。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>原生异步：\u003C\u002Fstrong>基于 Python asyncio，所有浏览器操作都是协程，支持高并发 Tab 管理。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>最小化指纹：\u003C\u002Fstrong>不添加 \u003Ccode>--enable-automation\u003C\u002Fcode> 等可检测的启动参数，不修改 \u003Ccode>navigator\u003C\u002Fcode> 属性。\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Cp>根据 \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fultrafunkamsterdam\u002Fnodriver\" rel=\"noopener noreferrer\">nodriver 官方仓库\u003C\u002Fa>的说明，该项目的核心目标是\"在不修改浏览器的情况下，尽可能自然地驱动 Chrome\"。这意味着不 patch Chrome 二进制文件，不注入 JavaScript 来隐藏自动化痕迹——而是通过 CDP 协议本身来实现控制。\u003C\u002Fp>\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fchromedevtools.github.io\u002Fdevtools-protocol\u002F\" rel=\"noopener noreferrer\">Chrome DevTools Protocol\u003C\u002Fa> 是 Chrome 内置的调试接口，通过 WebSocket 通信。nodriver 直接使用这个协议，绕过了 WebDriver 层，从而避免了该层引入的所有可检测特征。这正是 \u003Cstrong>nodriver 隐身\u003C\u002Fstrong>能力的核心来源。\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\u003Cth>特性\u003C\u002Fth>\u003Cth>nodriver\u003C\u002Fth>\u003Cth>undetected-chromedriver\u003C\u002Fth>\u003Cth>Playwright\u003C\u002Fth>\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\u003Ctd>底层协议\u003C\u002Ftd>\u003Ctd>CDP (WebSocket)\u003C\u002Ftd>\u003Ctd>WebDriver + CDP\u003C\u002Ftd>\u003Ctd>CDP + WebDriver\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>异步支持\u003C\u002Ftd>\u003Ctd>原生 asyncio\u003C\u002Ftd>\u003Ctd>否（同步）\u003C\u002Ftd>\u003Ctd>原生 async\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>navigator.webdriver\u003C\u002Ftd>\u003Ctd>不暴露\u003C\u002Ftd>\u003Ctd>隐藏但有残留\u003C\u002Ftd>\u003Ctd>暴露\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>代理认证\u003C\u002Ftd>\u003Ctd>CDP Fetch 域\u003C\u002Ftd>\u003Ctd>Chrome 扩展\u003C\u002Ftd>\u003Ctd>内置 API\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>内存占用\u002F实例\u003C\u002Ftd>\u003Ctd>~300MB\u003C\u002Ftd>\u003Ctd>~350MB\u003C\u002Ftd>\u003Ctd>~250MB\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>反检测能力\u003C\u002Ftd>\u003Ctd>高\u003C\u002Ftd>\u003Ctd>中\u003C\u002Ftd>\u003Ctd>低\u003C\u002Ftd>\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Ch2>nodriver 惯用 API：异步 Tab 与事件钩子\u003C\u002Fh2>\n\u003Cp>nodriver 的 API 设计与 Selenium 有本质区别。没有 \u003Ccode>WebDriverWait\u003C\u002Fcode>、没有 \u003Ccode>expected_conditions\u003C\u002Fcode>——所有等待都通过 \u003Ccode>await\u003C\u002Fcode> 和事件钩子实现。这种 nodriver 异步模型是高效爬取的基础。\u003C\u002Fp>\n\u003Ch3>核心对象模型\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>\u003Ccode>uc.start()\u003C\u002Fcode>：启动 Chrome，返回 \u003Ccode>Browser\u003C\u002Fcode> 对象\u003C\u002Fli>\n\u003Cli>\u003Ccode>Browser\u003C\u002Fcode>：管理浏览器实例，可创建多个 \u003Ccode>Tab\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>\u003Ccode>Tab\u003C\u002Fcode>：对应一个浏览器标签页，所有页面操作在此进行\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3>基本操作示例\u003C\u002Fh3>\n\u003Cpre>\u003Ccode>import nodriver as uc\nimport asyncio\n\nasync def main():\n    browser = await uc.start(headless=False)\n    tab = await browser.get(&quot;https:\u002F\u002Fnowsecure.nl&quot;)\n    \n    # 等待元素出现（替代 WebDriverWait）\n    await tab.select(&quot;body&quot;)\n    \n    # 查找元素并交互\n    button = await tab.find(&quot;button#submit&quot;)\n    if button:\n        await button.click()\n    \n    # 获取页面内容\n    html = await tab.get_content()\n    print(html[:500])\n\nasyncio.run(main())\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>关键区别在于 \u003Ccode>tab.select()\u003C\u002Fcode> 和 \u003Ccode>tab.find()\u003C\u002Fcode> 都是异步的——它们内部使用 CDP 的 \u003Ccode>DOM.querySelector\u003C\u002Fcode> 和轮询机制，不需要显式等待。如果元素不存在，\u003Ccode>select()\u003C\u002Fcode> 会持续等待直到超时，而 \u003Ccode>find()\u003C\u002Fcode> 立即返回 \u003Ccode>None\u003C\u002Fcode> 或抛出异常。\u003C\u002Fp>\n\u003Ch3>事件钩子替代轮询\u003C\u002Fh3>\n\u003Cp>nodriver 支持通过 CDP 事件钩子来响应页面变化，而非轮询 DOM。这比 Selenium 的轮询更高效，也更适合并发控制：\u003C\u002Fp>\n\u003Cpre>\u003Ccode>import nodriver as uc\nfrom nodriver import cdp\n\nasync def main():\n    browser = await uc.start()\n    tab = await browser.get(&quot;https:\u002F\u002Fexample.com&quot;)\n    \n    # 监听网络响应\n    async def on_response(event):\n        print(f&quot;Response: {event.response.url}&quot;)\n    \n    tab.add_handler(cdp.network.Response, on_response)\n    \n    await tab.select(&quot;body&quot;)\n\nasyncio.run(main())\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>这种事件驱动模式让 nodriver 可以在不阻塞主循环的情况下监听网络请求、DOM 变更和 console 消息，非常适合构建复杂的爬取流水线。\u003C\u002Fp>\n\u003Ch2>配置 nodriver 代理：--proxy-server 与住宅 IP\u003C\u002Fh2>\n\u003Cp>nodriver 没有内置代理轮换功能——这是设计选择，不是缺陷。你需要通过 Chrome 的 \u003Ccode>--proxy-server\u003C\u002Fcode> 启动参数设置代理，并通过 CDP Fetch 域处理认证。这种框架惯用的扩展方式让代理集成更加灵活。\u003C\u002Fp>\n\u003Ch3>为什么住宅代理对 nodriver 至关重要\u003C\u002Fh3>\n\u003Cp>即使用 nodriver 去除了所有浏览器指纹，如果请求来自数据中心 IP 段，Cloudflare 仍然会基于 IP 信誉进行拦截。住宅代理使用真实 ISP 分配的 IP 地址，信誉远高于数据中心 IP。对于 nodriver 网页爬取，住宅代理几乎是必需品。\u003C\u002Fp>\n\u003Cp>ProxyHat 提供的住宅代理具有 99.9% 可用率，覆盖全球 195+ 国家\u002F地区，支持按国家和城市定位。详见 \u003Ca href=\"\u002Fcn\u002Flocations\">代理位置列表\u003C\u002Fa>。\u003C\u002Fp>\n\u003Ch3>代理认证的挑战\u003C\u002Fh3>\n\u003Cp>Chrome 的 \u003Ccode>--proxy-server\u003C\u002Fcode> 参数只接受 \u003Ccode>host:port\u003C\u002Fcode>，不支持在 URL 中嵌入用户名密码。nodriver 通过 CDP 的 \u003Ccode>Fetch\u003C\u002Fcode> 域来解决这个问题：\u003C\u002Fp>\n\u003Col>\n\u003Cli>启用 \u003Ccode>Fetch.enable\u003C\u002Fcode> 并设置 \u003Ccode>handleAuthRequests=True\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>监听 \u003Ccode>Fetch.authRequired\u003C\u002Fcode> 事件，提供 ProxyHat 凭证\u003C\u002Fli>\n\u003Cli>监听 \u003Ccode>Fetch.requestPaused\u003C\u002Fcode> 事件，放行正常请求\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Ch3>ProxyHat 凭证构建器\u003C\u002Fh3>\n\u003Cpre>\u003Ccode>def build_proxy_credentials(\n    country: str = &quot;US&quot;,\n    region: str | None = None,\n    city: str | None = None,\n    session_id: str | None = None,\n) -&gt; tuple[str, str]:\n    &quot;&quot;&quot;构建 ProxyHat 代理用户名，支持地理定位和粘性会话。&quot;&quot;&quot;\n    username = &quot;user&quot;\n    if country:\n        username += f&quot;-country-{country}&quot;\n    if region and city:\n        username += f&quot;-region-{region}-city-{city}&quot;\n    elif region:\n        username += f&quot;-region-{region}&quot;\n    if session_id:\n        username += f&quot;-sid-{session_id}&quot;\n    return username, &quot;your_password&quot;\n\n# 示例：美国住宅 IP + 粘性会话\nuser, pwd = build_proxy_credentials(country=&quot;US&quot;, session_id=&quot;abc123&quot;)\n# user = &quot;user-country-US-sid-abc123&quot;\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>关于会话保持：相同 \u003Ccode>session_id\u003C\u002Fcode> 会在一段时间内保持同一出口 IP，适合需要登录状态或购物车流程的场景。如需每次请求换 IP，省略 \u003Ccode>session_id\u003C\u002Fcode> 即可。定价详情见 \u003Ca href=\"\u002Fcn\u002Fpricing\">ProxyHat 定价页\u003C\u002Fa>。\u003C\u002Fp>\n\u003Ch2>完整示例：住宅代理 + 会话保持爬取\u003C\u002Fh2>\n\u003Cp>以下是一个完整的可运行示例，展示如何启动 nodriver，通过 ProxyHat 美国住宅代理访问受保护页面，并提取 JSON 数据：\u003C\u002Fp>\n\u003Cpre>\u003Ccode>import nodriver as uc\nfrom nodriver import cdp\nimport asyncio\n\nPROXY_HOST = &quot;gate.proxyhat.com&quot;\nPROXY_PORT = 8080\n\ndef build_proxy_user(country=&quot;US&quot;, session_id=&quot;abc123&quot;):\n    return f&quot;user-country-{country}-sid-{session_id}&quot;\n\nasync def main():\n    proxy_user = build_proxy_user(country=&quot;US&quot;, session_id=&quot;abc123&quot;)\n    proxy_pass = &quot;your_password&quot;\n    \n    browser = await uc.start(\n        browser_args=[\n            f&quot;--proxy-server=http:\u002F\u002F{PROXY_HOST}:{PROXY_PORT}&quot;,\n        ],\n        headless=False,\n    )\n    \n    tab = await browser.get(&quot;about:blank&quot;)\n    \n    # 启用 CDP Fetch 域处理代理认证\n    await tab.send(cdp.fetch.Enable(handle_auth_requests=True))\n    \n    async def on_auth_required(event):\n        await tab.send(\n            cdp.fetch.ContinueWithAuth(\n                request_id=event.request_id,\n                auth_challenge_response=cdp.fetch.AuthChallengeResponse(\n                    response=&quot;ProvideCredentials&quot;,\n                    username=proxy_user,\n                    password=proxy_pass,\n                ),\n            )\n        )\n    \n    async def on_request_paused(event):\n        await tab.send(\n            cdp.fetch.ContinueRequest(request_id=event.request_id)\n        )\n    \n    tab.add_handler(cdp.fetch.AuthRequired, on_auth_required)\n    tab.add_handler(cdp.fetch.RequestPaused, on_request_paused)\n    \n    # 访问受保护页面\n    await tab.get(&quot;https:\u002F\u002Fhttpbin.org\u002Fip&quot;)\n    await tab.select(&quot;body&quot;)\n    \n    # 提取 JSON\n    html = await tab.get_content()\n    print(html)\n    \n    browser.stop()\n\nasyncio.run(main())\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>这个示例中，nodriver 通过 \u003Ccode>gate.proxyhat.com:8080\u003C\u002Fcode> 连接 ProxyHat 住宅代理，使用 \u003Ccode>user-country-US-sid-abc123\u003C\u002Fcode> 凭证实现美国出口 IP 和粘性会话。CDP Fetch 域在 WebSocket 层处理 HTTP 407 代理认证挑战，对页面 JavaScript 完全透明。\u003C\u002Fp>\n\u003Cp>对于 SOCKS5 代理，只需将端口改为 \u003Ccode>1080\u003C\u002Fcode>，并将 \u003Ccode>--proxy-server\u003C\u002Fcode> 参数改为 \u003Ccode>socks5:\u002F\u002Fgate.proxyhat.com:1080\u003C\u002Fcode>。更多配置选项请参考 \u003Ca href=\"https:\u002F\u002Fdocs.proxyhat.com\u002F\" rel=\"noopener noreferrer\">ProxyHat 官方文档\u003C\u002Fa>。\u003C\u002Fp>\n\u003Ch2>扩展 nodriver 爬取：并发 Tab 与 Docker 集群\u003C\u002Fh2>\n\u003Ch3>并发 Tab 管理\u003C\u002Fh3>\n\u003Cp>nodriver 的异步架构天然支持并发 Tab。以下示例展示同时爬取多个 URL，每个 Tab 使用独立的代理会话：\u003C\u002Fp>\n\u003Cpre>\u003Ccode>import nodriver as uc\nfrom nodriver import cdp\nimport asyncio\n\nasync def scrape_with_proxy(browser, url, session_id):\n    proxy_user = f&quot;user-country-US-sid-{session_id}&quot;\n    proxy_pass = &quot;your_password&quot;\n    \n    tab = await browser.get(&quot;about:blank&quot;)\n    await tab.send(cdp.fetch.Enable(handle_auth_requests=True))\n    \n    async def on_auth(event):\n        await tab.send(cdp.fetch.ContinueWithAuth(\n            request_id=event.request_id,\n            auth_challenge_response=cdp.fetch.AuthChallengeResponse(\n                response=&quot;ProvideCredentials&quot;,\n                username=proxy_user,\n                password=proxy_pass,\n            ),\n        ))\n    \n    async def on_pause(event):\n        await tab.send(cdp.fetch.ContinueRequest(\n            request_id=event.request_id\n        ))\n    \n    tab.add_handler(cdp.fetch.AuthRequired, on_auth)\n    tab.add_handler(cdp.fetch.RequestPaused, on_pause)\n    \n    await tab.get(url)\n    await tab.select(&quot;body&quot;)\n    content = await tab.get_content()\n    await tab.close()\n    return content\n\nasync def main():\n    browser = await uc.start(\n        browser_args=[&quot;--proxy-server=http:\u002F\u002Fgate.proxyhat.com:8080&quot;],\n        headless=True,\n    )\n    \n    urls = [\n        &quot;https:\u002F\u002Fhttpbin.org\u002Fip&quot;,\n        &quot;https:\u002F\u002Fhttpbin.org\u002Fheaders&quot;,\n        &quot;https:\u002F\u002Fhttpbin.org\u002Fuser-agent&quot;,\n    ]\n    \n    tasks = [\n        scrape_with_proxy(browser, url, f&quot;sess{i}&quot;)\n        for i, url in enumerate(urls)\n    ]\n    \n    results = await asyncio.gather(*tasks)\n    for r in results:\n        print(r[:200])\n\nasyncio.run(main())\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>单个 Chrome 实例可承载 10-20 个并发 Tab，具体取决于页面复杂度和内存。每个 Tab 约 30-50MB 内存开销。对于更高并发，建议启动多个 Chrome 实例。\u003C\u002Fp>\n\u003Ch3>Docker 无头集群部署\u003C\u002Fh3>\n\u003Cp>在生产环境中，推荐用 Docker 容器化每个 Chrome 实例，实现水平扩展：\u003C\u002Fp>\n\u003Cpre>\u003Ccode># Dockerfile\nFROM python:3.12-slim\n\nRUN apt-get update &amp;&amp; apt-get install -y \\\n    chromium chromium-driver \\\n    fonts-noto-cjk \\\n    &amp;&amp; rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\nRUN pip install nodriver\n\nCOPY scraper.py .\nCMD [&quot;python&quot;, &quot;-u&quot;, &quot;scraper.py&quot;]\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cpre>\u003Ccode># docker-compose.yml\nversion: &quot;3.8&quot;\nservices:\n  scraper:\n    build: .\n    environment:\n      - PROXY_HOST=gate.proxyhat.com\n      - PROXY_PORT=8080\n      - PROXY_USER=user-country-US\n      - PROXY_PASS=your_password\n    deploy:\n      replicas: 5\n    resources:\n      limits:\n        memory: 512M\n        cpus: &quot;1.0&quot;\n    restart: unless-stopped\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>通过 \u003Ccode>replicas: 5\u003C\u002Fcode> 启动 5 个容器，每个运行一个 Chrome 实例，可实现 50-100 并发会话。配合 ProxyHat 的 \u003Ca href=\"\u002Fcn\u002Fuse-cases\u002Fweb-scraping\">网页爬取代理\u003C\u002Fa>，每个容器可分配不同国家的出口 IP。\u003C\u002Fp>\n\u003Ch3>优雅关闭\u003C\u002Fh3>\n\u003Cp>nodriver 的 \u003Ccode>browser.stop()\u003C\u002Fcode> 会关闭所有 Tab 和 WebSocket 连接。在容器环境中，建议注册信号处理器确保优雅退出：\u003C\u002Fp>\n\u003Cpre>\u003Ccode>import signal\nimport asyncio\n\nshutdown = asyncio.Event()\n\ndef handle_signal(signum, frame):\n    shutdown.set()\n\nsignal.signal(signal.SIGTERM, handle_signal)\nsignal.signal(signal.SIGINT, handle_signal)\n\nasync def main():\n    browser = await uc.start(...)\n    # ... 爬取逻辑 ...\n    await shutdown.wait()\n    browser.stop()\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>这确保 Kubernetes 或 Docker Swarm 发送 SIGTERM 时，浏览器会正确关闭而非被强制杀死，避免僵尸 Chrome 进程。\u003C\u002Fp>\n\u003Ch2>何时不用浏览器：curl_cffi 更经济\u003C\u002Fh2>\n\u003Cp>nodriver 虽然隐蔽，但每个 Chrome 实例占用 ~300MB 内存，启动时间 2-5 秒。对于不需要 JavaScript 渲染的场景，使用 HTTP 客户端加 TLS 指纹模拟是更高效的选择。\u003C\u002Fp>\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Flexiforest\u002Fcurl_cffi\" rel=\"noopener noreferrer\">curl_cffi\u003C\u002Fa> 是一个 Python 库，使用 curl 的 impersonate 功能模拟真实浏览器的 TLS 指纹（包括 JA3\u002FJA4），内存占用仅 ~50MB，吞吐量可达 1500 请求\u002F秒。\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\u003Cth>场景\u003C\u002Fth>\u003Cth>推荐工具\u003C\u002Fth>\u003Cth>理由\u003C\u002Fth>\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\u003Ctd>纯 API JSON 抓取\u003C\u002Ftd>\u003Ctd>curl_cffi + ProxyHat\u003C\u002Ftd>\u003Ctd>无需 JS 渲染，速度快 10 倍\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>Cloudflare JS 挑战\u003C\u002Ftd>\u003Ctd>nodriver + ProxyHat\u003C\u002Ftd>\u003Ctd>需要执行 JS 通过挑战\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>SERP 追踪\u003C\u002Ftd>\u003Ctd>curl_cffi 或 nodriver\u003C\u002Ftd>\u003Ctd>取决于反爬强度\u003C\u002Ftd>\u003C\u002Ftr>\n\u003Ctr>\u003Ctd>动态 SPA 页面\u003C\u002Ftd>\u003Ctd>nodriver + ProxyHat\u003C\u002Ftd>\u003Ctd>需要完整 DOM 渲染\u003C\u002Ftd>\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>对于 \u003Ca href=\"\u002Fcn\u002Fuse-cases\u002Fserp-tracking\">SERP 追踪\u003C\u002Fa>等场景，建议先用 curl_cffi 测试，如果遇到 JS 挑战再切换到 nodriver。这样可以大幅降低基础设施成本。\u003C\u002Fp>","使用 nodriver 爬取：异步CDP代理配置指南 | ProxyHat","深入学习使用 nodriver 爬取：通过 CDP WebSocket 直连 Chrome，实现零 WebDriver 残留的隐身爬取。完整指南涵盖 ProxyHat 住宅代理认证配置、粘性会话、并发 Tab 扩展、Docker 集群部署，帮助你稳定绕过 Cloudflare 与 Imperva 反爬虫检测。","\u002Fcn\u002Fblog\u002Fnodriver-pachong-daili-shizhan",null,"使用 nodriver 爬取：CDP代理配置指南 | ProxyHat","深入学习使用 nodriver 爬取：通过 CDP 直连 Chrome 实现隐身爬取。涵盖 ProxyHat 住宅代理配置、并发扩展与 Docker 部署。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fnodriver-pachong-daili-shizhan-og.webp",[19,22,25],{"question":20,"answer":21},"什么是使用 nodriver 爬取？","使用 nodriver 爬取是指通过 nodriver 库驱动 Chrome 浏览器进行网页数据采集。nodriver 是 undetected-chromedriver 的继任者，基于 Python asyncio 和 Chrome DevTools Protocol，不依赖 Selenium WebDriver，因此不暴露 navigator.webdriver 标志，能更有效地绕过 Cloudflare 和 Imperva 等反爬检测。",{"question":23,"answer":24},"为什么使用 nodriver 爬取对代理用户很重要？","nodriver 去除了浏览器层面的自动化指纹，但 IP 层面的检测仍然存在。如果使用数据中心 IP，即使浏览器指纹完美，Cloudflare 仍会基于 IP 信誉拦截请求。因此 nodriver 爬取必须配合住宅代理，确保 IP 层面也不被识别为自动化流量。",{"question":26,"answer":27},"如何在使用 nodriver 爬取时避免被封？","除了使用住宅代理外，还应设置合理的请求间隔（每次请求间隔 2-5 秒），使用粘性会话保持同一 IP，限制单 IP 并发数不超过 10，以及遵守 robots.txt 和目标网站服务条款。结合 nodriver 的隐身能力和 ProxyHat 住宅代理，可显著降低被封风险。",[29,30,31,32,33],"nodriver 是 undetected-chromedriver 的继任者，通过 CDP 直连 Chrome 消除 WebDriver 指纹，实现隐蔽爬取。","代理认证需通过 CDP Fetch 域处理，配合 --proxy-server 参数实现住宅代理的连接与认证。","即使浏览器指纹完美，也必须使用住宅代理，否则数据中心 IP 会被 Cloudflare 基于 IP 信誉拦截。","并发爬取可通过单实例多 Tab 和 Docker 容器集群水平扩展，实现 50-100 并发会话。","对于无需 JS 渲染的纯 API 抓取，使用 curl_cffi 模拟 TLS 指纹成本更低且吞吐量更高。",false,"2026-07-06T10:04:03+00:00","2026-10-03T23:53:01+00:00","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fnodriver-pachong-daili-shizhan-master.webp","Scraping With nodriver: A Practical Guide to Async CDP + Residential Proxies","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fnodriver-pachong-daili-shizhan-card.webp",12,{"name":42,"slug":43,"bio":44,"avatar_url":14,"website_url":14,"social_links":14},"ProxyHat Team","proxyhat-team","The ProxyHat editorial team covers proxies, web scraping, and data extraction.",[46],{"id":47,"slug":48,"name":49,"description":14,"meta_title":50,"meta_description":51,"parent_id":14},4,"kaifa-zhinan","开发者指南","开发者指南 | ProxyHat 博客","代码教程和SDK指南，帮助您将代理集成到应用程序中。",[],{"ko":54,"ja":55,"en":56,"fr":57,"ru":58,"tr":59,"x-default":56},"\u002Fko\u002Fblog\u002Fnodriver-proxy-scraping-guide","\u002Fja\u002Fblog\u002Fnodriver-scraping-nyumon","\u002Fblog\u002Fscraping-with-nodriver-proxy-guide","\u002Ffr\u002Fblog\u002Fscraping-avec-nodriver-proxy","\u002Fru\u002Fblog\u002Fskrejping-s-nodriver-prakticheskoe-rukovodstvo","\u002Ftr\u002Fblog\u002Fnodriver-ile-web-scraping",{"ko":54,"ja":55,"zh":13,"de":61,"es":62,"it":63,"en":56,"fr":57,"ru":58,"pt":64,"pl":65,"tr":59},"\u002Fde\u002Fblog\u002Fscraping-mit-nodriver-proxies","\u002Fes\u002Fblog\u002Fscraping-con-nodriver-proxies","\u002Fit\u002Fblog\u002Fscraping-con-nodriver-proxy-residenziali","\u002Fpt\u002Fblog\u002Fcomo-usar-nodriver-proxies-residenciais","\u002Fpl\u002Fblog\u002Fscraping-z-nodriver-przewodnik",541,[68,102,129,145],{"id":69,"slug":70,"title":71,"excerpt":72,"featured_image_url":73,"featured_image_alt":74,"card_image_url":75,"og_image_url":76,"published_at":77,"updated_at":78,"content_updated_at":79,"reading_time_minutes":80,"is_featured":34,"indexable":4,"views":81,"author":82,"categories":83,"tags":85},210,"ai-agent-daili-peizhi","AI Agent 代理配置：browser-use、Crawl4AI、MCP","运行在云服务器上的智能体从数据中心 IP 出口。本文给出 browser-use、Crawl4AI 和 MCP 服务器当前可用的代理配置，附粘性与轮换的决策表，以及需要避开的成本陷阱。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fai-agent-daili-peizhi-master.webp","Proxy Setup for AI Agents: browser-use, Crawl4AI and an MCP Server","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fai-agent-daili-peizhi-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fai-agent-daili-peizhi-og.webp","2026-10-24T09:00:00+00:00","2026-10-24T09:00:20+00:00","2026-10-03T09:41:40+00:00",14,31,{"name":42,"slug":43,"bio":44,"avatar_url":14,"website_url":14,"social_links":14},[84],{"id":47,"slug":48,"name":49,"description":14,"meta_title":50,"meta_description":51,"parent_id":14},[86,90,94,98],{"id":87,"slug":88,"name":89},1,"web-scraping","网页抓取",{"id":91,"slug":92,"name":93},2,"residential-proxies","住宅代理",{"id":95,"slug":96,"name":97},9,"python","Python",{"id":99,"slug":100,"name":101},22,"playwright","Playwright",{"id":103,"slug":104,"title":105,"excerpt":106,"featured_image_url":107,"featured_image_alt":108,"card_image_url":109,"og_image_url":110,"published_at":111,"updated_at":112,"content_updated_at":79,"reading_time_minutes":80,"is_featured":34,"indexable":4,"views":113,"author":114,"categories":115,"tags":117},206,"camoufox-zhuzhai-daili-python-zhinan","Camoufox 搭配住宅代理：代码优先的 Python 指南","如何让在 C++ 层打补丁的 Firefox——Camoufox 在住宅代理后运行：当前的 Python API、geoip 为什么需要粘性会话、指纹一致性检查清单，以及何时 Patchright 或 nodriver 更合适。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fcamoufox-zhuzhai-daili-python-zhinan-master.webp","Camoufox with Residential Proxies: A Code-First Python Guide","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fcamoufox-zhuzhai-daili-python-zhinan-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fcamoufox-zhuzhai-daili-python-zhinan-og.webp","2026-10-13T09:00:00+00:00","2026-10-13T09:00:22+00:00",44,{"name":42,"slug":43,"bio":44,"avatar_url":14,"website_url":14,"social_links":14},[116],{"id":47,"slug":48,"name":49,"description":14,"meta_title":50,"meta_description":51,"parent_id":14},[118,119,120,124,125],{"id":87,"slug":88,"name":89},{"id":91,"slug":92,"name":93},{"id":121,"slug":122,"name":123},6,"anti-detection","反检测",{"id":95,"slug":96,"name":97},{"id":126,"slug":127,"name":128},21,"headless-browser","无头浏览器",{"id":130,"slug":131,"title":132,"excerpt":133,"featured_image_url":134,"featured_image_alt":135,"card_image_url":136,"og_image_url":137,"published_at":138,"updated_at":138,"content_updated_at":139,"reading_time_minutes":40,"is_featured":34,"indexable":4,"views":140,"author":141,"categories":142,"tags":144},176,"got-scraping-nodejs-proxy-guide","Node.js 中的 got-scraping 完整指南：头部生成与住宅代理实战","深入解析 Apify 的 got-scraping 库——从 header-generator 生成连贯浏览器头部、HTTP\u002F2 支持，到通过 ProxyHat 住宅代理实现大规模 Node.js 爬虫。包含可运行代码、重试钩子、并发控制与生产模式最佳实践。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fgot-scraping-nodejs-proxy-guide-master.webp","got-scraping in Node.js: A Developer's Guide with Residential Proxies","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fgot-scraping-nodejs-proxy-guide-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fgot-scraping-nodejs-proxy-guide-og.webp","2026-08-04T16:05:06+00:00","2026-10-03T08:29:58+00:00",130,{"name":42,"slug":43,"bio":44,"avatar_url":14,"website_url":14,"social_links":14},[143],{"id":47,"slug":48,"name":49,"description":14,"meta_title":50,"meta_description":51,"parent_id":14},[],{"id":146,"slug":147,"title":148,"excerpt":149,"featured_image_url":150,"featured_image_alt":151,"card_image_url":152,"og_image_url":153,"published_at":154,"updated_at":154,"content_updated_at":155,"reading_time_minutes":40,"is_featured":34,"indexable":34,"views":156,"author":157,"categories":158,"tags":160},175,"colly-lunhuan-daili-shixian-zhinan","Colly轮换代理完整指南：用Go构建高吞吐爬虫的实战方案","深入讲解如何在Go的Colly框架中实现代理轮换，涵盖RoundRobinProxySwitcher、SetProxyFunc自定义函数、住宅代理地理定位与会话保持、生产级重试与并发控制，以及分布式存储后端等核心模式。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fcolly-lunhuan-daili-shixian-zhinan-master.webp","Rotating Proxies in Colly: A Framework-Idiomatic Guide for Go Developers","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fcolly-lunhuan-daili-shixian-zhinan-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fcolly-lunhuan-daili-shixian-zhinan-og.webp","2026-08-04T10:05:34+00:00","2026-10-03T08:29:56+00:00",81,{"name":42,"slug":43,"bio":44,"avatar_url":14,"website_url":14,"social_links":14},[159],{"id":47,"slug":48,"name":49,"description":14,"meta_title":50,"meta_description":51,"parent_id":14},[],[]]