[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"blog-post-cn-amazon-guanjianci-paiming-zhuizong-daili-1":3},{"success":4,"payload":5,"related":63,"errors":128},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":11,"og_description":15,"og_image_url":16,"faq_json":17,"key_takeaways":24,"allow_index":30,"noindex_google_only":30,"allow_follow":4,"published_at":31,"updated_at":31,"content_updated_at":32,"featured_image_url":33,"featured_image_alt":34,"card_image_url":35,"reading_time_minutes":36,"author":37,"categories":41,"tags":48,"alternates":49,"locale_paths":53,"views":62},155,"amazon-guanjianci-paiming-zhuizong-daili-1","使用代理追踪亚马逊关键词排名：开发者完整指南","面向亚马逊卖家和 SEO 开发者的代码实战指南——用住宅代理、Python 和 Playwright\u002Fcurl_cffi 追踪关键词自然排名，解析搜索结果页，分离广告与自然位，并覆盖生产级重试、CAPTCHA 检测与合规注意事项。","\u003Cblockquote>\u003Cp>\u003Cstrong>法律与合规声明：\u003C\u002Fstrong>本文仅涉及公开搜索数据的采集。在美国，需遵守 \u003Ca href=\"https:\u002F\u002Fwww.law.cornell.edu\u002Fuscode\u002Ftext\u002F18\u002F1030\" rel=\"noopener noreferrer\">《计算机欺诈和滥用法》(CFAA)\u003C\u002Fa> 的相关规定；在欧盟，需遵守 \u003Ca href=\"https:\u002F\u002Fgdpr-info.eu\u002F\" rel=\"noopener noreferrer\">GDPR\u003C\u002Fa> 对个人数据的保护要求。请勿绕过技术访问控制措施、采集非公开数据，或违反亚马逊服务条款。建议优先使用 \u003Ca href=\"https:\u002F\u002Fdeveloper-docs.amazon\u002Fsp-api\u002F\" rel=\"noopener noreferrer\">Amazon SP-API\u003C\u002Fa> 获取合规数据。本指南面向追踪自有商品列表和公开搜索结果的场景。\u003C\u002Fp>\u003C\u002Fblockquote>\u003Ch2>为什么使用代理追踪亚马逊关键词排名是卖家的核心需求\u003C\u002Fh2>\u003Cp>亚马逊搜索是一个独立于 Google 的 SERP 生态系统。排名算法由\u003Cstrong>相关性\u003C\u002Fstrong>和销售速度（sales velocity）驱动，而非传统的链接权重。这意味着卖家必须持续追踪自己产品（ASIN）在特定关键词、特定市场（marketplace）下的自然排名位置——这正是「亚马逊关键词排名追踪器」的核心场景。\u003C\u002Fp>\u003Cp>与 Google SERP 不同，亚马逊的搜索结果高度本地化：不同国家、邮编、甚至设备类型返回的排名可能完全不同。一个在美国纽约搜索 \"bluetooth speaker\" 的用户看到的结果，与德国柏林的用户看到的结果截然不同。如果卖家只用单一 IP 从一个地理位置抓取，得到的排名数据无法反映目标市场真实买家的视角。\u003C\u002Fp>\u003Cp>使用代理追踪亚马逊关键词排名解决了两个核心问题：\u003Cstrong>地理准确性\u003C\u002Fstrong>（通过住宅代理的国家级地理定位获取目标市场真实排名）和\u003Cstrong>反爬规避\u003C\u002Fstrong>（通过 IP 轮换和真实住宅 IP 降低被封风险）。本文将从技术实现角度，带你完整搭建一套生产级的排名追踪系统。\u003C\u002Fp>\u003Ch2>技术背景：亚马逊搜索结果页的结构\u003C\u002Fh2>\u003Cp>亚马逊搜索结果页的 HTML 结构相对稳定。每个商品结果被包裹在一个带有 \u003Ccode>data-component-type=\"s-search-result\"\u003C\u002Fcode> 属性的 div 中，ASIN 存储在 \u003Ccode>data-asin\u003C\u002Fcode> 属性里。广告位（Sponsored）通过结果卡片内的 \"Sponsored\" 文本标签标识。理解这些结构是解析排名的基础。\u003C\u002Fp>\u003Cp>关键解析逻辑如下：\u003C\u002Fp>\u003Cul>\u003Cli>\u003Cstrong>定位结果容器\u003C\u002Fstrong>：遍历所有 \u003Ccode>[data-component-type=\"s-search-result\"]\u003C\u002Fcode> 元素\u003C\u002Fli>\u003Cli>提取 ASIN：读取 \u003Ccode>data-asin\u003C\u002Fcode> 属性，空值通常为广告或非商品卡片\u003C\u002Fli>\u003Cli>区分自然位与广告位：检测卡片内是否包含 \"Sponsored\" 文本\u003C\u002Fli>\u003Cli>计算自然排名：仅对非广告结果计数，得到目标 ASIN 的自然位\u003C\u002Fli>\u003C\u002Ful>\u003Cp>亚马逊的 A\u002FB 测试和前端改版时有发生，因此解析代码需要具备容错能力——当选择器失效时记录错误而非直接崩溃。\u003C\u002Fp>\u003Ch2>代理类型对比：住宅 vs 数据中心 vs 移动\u003C\u002Fh2>\u003Cp>选择正确的代理类型是亚马逊排名追踪成功的关键。以下是三种代理的对比：\u003C\u002Fp>\u003Ctable>\u003Cthead>\u003Ctr>\u003Cth>特性\u003C\u002Fth>\u003Cth>住宅代理\u003C\u002Fth>\u003Cth>数据中心代理\u003C\u002Fth>\u003Cth>移动代理\u003C\u002Fth>\u003C\u002Ftr>\u003C\u002Fthead>\u003Ctbody>\u003Ctr>\u003Ctd>IP 来源\u003C\u002Ftd>\u003Ctd>真实 ISP 分配的住宅 IP\u003C\u002Ftd>\u003Ctd>云服务商 IP 段\u003C\u002Ftd>\u003Ctd>移动运营商 IP\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>亚马逊封禁风险\u003C\u002Ftd>\u003Ctd>低\u003C\u002Ftd>\u003Ctd>高（通常 3-5 次请求后触发）\u003C\u002Ftd>\u003Ctd>极低\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>地理定位精度\u003C\u002Ftd>\u003Ctd>国家\u002F城市级\u003C\u002Ftd>\u003Ctd>国家级（不准确）\u003C\u002Ftd>\u003Ctd>国家\u002F运营商级\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>响应延迟\u003C\u002Ftd>\u003Ctd>200-800ms\u003C\u002Ftd>\u003Ctd>50-150ms\u003C\u002Ftd>\u003Ctd>500-2000ms\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>适用场景\u003C\u002Ftd>\u003Ctd>桌面端排名追踪\u003C\u002Ftd>\u003Ctd>不推荐\u003C\u002Ftd>\u003Ctd>移动端排名追踪\u003C\u002Ftd>\u003C\u002Ftr>\u003Ctr>\u003Ctd>成本\u003C\u002Ftd>\u003Ctd>中等\u003C\u002Ftd>\u003Ctd>最低\u003C\u002Ftd>\u003Ctd>最高\u003C\u002Ftd>\u003C\u002Ftr>\u003C\u002Ftbody>\u003C\u002Ftable>\u003Cp>对于亚马逊关键词排名追踪，住宅代理是首选。数据中心 IP 几乎在亚马逊上无法使用——亚马逊的反爬系统对已知云服务商 IP 段（AWS、GCP、Azure 等）有极高的识别率。\u003C\u002Fp>\u003Ch2>ProxyHat 代理配置：地理定位与粘性会话\u003C\u002Fh2>\u003Cp>ProxyHat 住宅代理通过用户名中的标志实现地理定位和会话管理。以下是亚马逊排名追踪的推荐配置：\u003C\u002Fp>\u003Ch3>国家地理定位\u003C\u002Fh3>\u003Cp>不同亚马逊站点需要匹配对应国家的代理 IP：\u003C\u002Fp>\u003Cpre>\u003Ccode># amazon.com → 美国住宅 IP\nhttp:\u002F\u002Fuser-country-US:pass@gate.proxyhat.com:8080\n\n# amazon.de → 德国住宅 IP\nhttp:\u002F\u002Fuser-country-DE:pass@gate.proxyhat.com:8080\n\n# amazon.co.uk → 英国住宅 IP\nhttp:\u002F\u002Fuser-country-GB:pass@gate.proxyhat.com:8080\n\n# amazon.co.jp → 日本住宅 IP\nhttp:\u002F\u002Fuser-country-JP:pass@gate.proxyhat.com:8080\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>粘性会话（Sticky Session）\u003C\u002Fh3>\u003Cp>翻页时必须保持同一 IP，否则不同页面的排名可能因 IP 切换而产生偏差。使用 \u003Ccode>-sid-\u003C\u002Fcode> 标志创建粘性会话：\u003C\u002Fp>\u003Cpre>\u003Ccode># 为同一关键词的翻页请求绑定同一 IP\nhttp:\u002F\u002Fuser-country-US-sid-kw123:pass@gate.proxyhat.com:8080\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>会话 ID 建议使用关键词 + 日期的组合（如 \u003Ccode>bluetooth-speaker-20260115\u003C\u002Fcode>），确保同一天同一关键词的所有页面来自同一 IP。不同关键词或不同天使用不同会话 ID，实现 IP 轮换。\u003C\u002Fp>\u003Cp>更多代理配置选项请参考 \u003Ca href=\"https:\u002F\u002Fdocs.proxyhat.com\u002F\" rel=\"noopener noreferrer\">ProxyHat 官方文档\u003C\u002Fa>，或查看 \u003Ca href=\"\u002Fcn\u002Flocations\">支持的代理位置\u003C\u002Fa>。\u003C\u002Fp>\u003Ch2>代码实战：用 Python 追踪亚马逊关键词排名\u003C\u002Fh2>\u003Cp>以下示例使用 \u003Ccode>curl_cffi\u003C\u002Fcode>（模拟浏览器 TLS 指纹）配合 ProxyHat 代理，抓取 amazon.com 上关键词 \"bluetooth speaker\" 的前 5 页搜索结果，定位目标 ASIN 的自然排名。\u003C\u002Fp>\u003Ch3>示例 1：使用 curl_cffi 抓取搜索结果\u003C\u002Fh3>\u003Cpre>\u003Ccode>import re\nimport time\nimport json\nimport logging\nfrom datetime import datetime\nfrom curl_cffi import requests as cffi_requests\n\nlogging.basicConfig(level=logging.INFO, format=&apos;%(asctime)s %(levelname)s %(message)s&apos;)\nlogger = logging.getLogger(__name__)\n\n# ProxyHat 代理配置\nPROXY_BASE = &quot;http:\u002F\u002Fuser-country-US-sid-{session}:pass@gate.proxyhat.com:8080&quot;\nTARGET_ASIN = &quot;B0DXXXXXXXX&quot;  # 替换为你的 ASIN\nKEYWORD = &quot;bluetooth speaker&quot;\nMARKETPLACE = &quot;www.amazon.com&quot;\nMAX_PAGES = 5\n\ndef build_proxy_url(session_id: str) -&gt; str:\n    &quot;&quot;&quot;构建带粘性会话的代理 URL&quot;&quot;&quot;\n    return PROXY_BASE.format(session=session_id)\n\ndef fetch_search_page(keyword: str, page: int, session_id: str) -&gt; str | None:\n    &quot;&quot;&quot;抓取亚马逊搜索结果单页 HTML&quot;&quot;&quot;\n    proxy_url = build_proxy_url(session_id)\n    proxies = {&quot;http&quot;: proxy_url, &quot;https&quot;: proxy_url}\n    \n    url = f&quot;https:\u002F\u002F{MARKETPLACE}\u002Fs&quot;\n    params = {&quot;k&quot;: keyword, &quot;page&quot;: page}\n    headers = {\n        &quot;User-Agent&quot;: &quot;Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36 (KHTML, like Gecko) Chrome\u002F120.0.0.0 Safari\u002F537.36&quot;,\n        &quot;Accept-Language&quot;: &quot;en-US,en;q=0.9&quot;,\n        &quot;Accept&quot;: &quot;text\u002Fhtml,application\u002Fxhtml+xml,application\u002Fxml;q=0.9,*\u002F*;q=0.8&quot;,\n    }\n    \n    for attempt in range(3):\n        try:\n            resp = cffi_requests.get(\n                url, params=params, headers=headers,\n                proxies=proxies, impersonate=&quot;chrome120&quot;,\n                timeout=30, allow_redirects=True\n            )\n            if resp.status_code == 200:\n                html = resp.text\n                if &quot;captcha&quot; in html.lower() or &quot;robot&quot; in html.lower():\n                    logger.warning(f&quot;CAPTCHA detected on page {page}, attempt {attempt+1}&quot;)\n                    time.sleep(5 * (attempt + 1))  # 退避\n                    continue\n                return html\n            elif resp.status_code == 503:\n                logger.warning(f&quot;503 on page {page}, retrying...&quot;)\n                time.sleep(3 * (attempt + 1))\n            else:\n                logger.error(f&quot;HTTP {resp.status_code} on page {page}&quot;)\n                return None\n        except Exception as e:\n            logger.error(f&quot;Request error on page {page}: {e}&quot;)\n            time.sleep(3 * (attempt + 1))\n    return None\n\ndef parse_rankings(html: str) -&gt; list[dict]:\n    &quot;&quot;&quot;解析搜索结果页，返回 ASIN 列表及自然\u002F广告标记&quot;&quot;&quot;\n    results = []\n    # 匹配所有 s-search-result 容器\n    pattern = r&apos;data-component-type=&quot;s-search-result&quot;[^&gt;]*data-asin=&quot;([A-Z0-9]+)&quot;[^&gt;]*&gt;&apos;\n    blocks = re.findall(r&apos;(&lt;div[^&gt;]*data-component-type=&quot;s-search-result&quot;.*?&lt;\u002Fdiv&gt;)&apos;, html, re.DOTALL)\n    \n    organic_position = 0\n    for block in blocks:\n        asin_match = re.search(r&apos;data-asin=&quot;([A-Z0-9]+)&quot;&apos;, block)\n        if not asin_match or not asin_match.group(1):\n            continue\n        asin = asin_match.group(1)\n        is_sponsored = &quot;Sponsored&quot; in block\n        if not is_sponsored:\n            organic_position += 1\n            results.append({\n                &quot;asin&quot;: asin,\n                &quot;organic_position&quot;: organic_position,\n                &quot;is_sponsored&quot;: False,\n            })\n        else:\n            results.append({\n                &quot;asin&quot;: asin,\n                &quot;organic_position&quot;: None,\n                &quot;is_sponsored&quot;: True,\n            })\n    return results\n\ndef track_keyword_rank(keyword: str, target_asin: str, max_pages: int) -&gt; dict:\n    &quot;&quot;&quot;追踪目标 ASIN 在指定关键词下的自然排名&quot;&quot;&quot;\n    session_id = re.sub(r&apos;[^a-z0-9]&apos;, &apos;-&apos;, keyword.lower())[:20]\n    all_results = []\n    \n    for page in range(1, max_pages + 1):\n        logger.info(f&quot;Fetching page {page} for &apos;{keyword}&apos;&quot;)\n        html = fetch_search_page(keyword, page, session_id)\n        if not html:\n            logger.error(f&quot;Failed to fetch page {page}&quot;)\n            break\n        results = parse_rankings(html)\n        all_results.extend(results)\n        time.sleep(3)  # 请求间隔\n    \n    # 查找目标 ASIN\n    target_result = None\n    for r in all_results:\n        if r[&quot;asin&quot;] == target_asin and not r[&quot;is_sponsored&quot;]:\n            target_result = r\n            break\n    \n    record = {\n        &quot;keyword&quot;: keyword,\n        &quot;asin&quot;: target_asin,\n        &quot;marketplace&quot;: MARKETPLACE,\n        &quot;timestamp&quot;: datetime.utcnow().isoformat(),\n        &quot;found&quot;: target_result is not None,\n        &quot;organic_position&quot;: target_result[&quot;organic_position&quot;] if target_result else None,\n        &quot;page&quot;: ((target_result[&quot;organic_position&quot;] - 1) \u002F\u002F 60 + 1) if target_result else None,\n    }\n    return record\n\n# 运行追踪\nif __name__ == &quot;__main__&quot;:\n    result = track_keyword_rank(KEYWORD, TARGET_ASIN, MAX_PAGES)\n    print(json.dumps(result, indent=2))\n    \n    # 保存到历史文件\n    with open(f&quot;rank_history_{TARGET_ASIN}.jsonl&quot;, &quot;a&quot;) as f:\n        f.write(json.dumps(result) + &quot;\\n&quot;)\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>示例 2：使用 Playwright 抓取（处理 JS 渲染）\u003C\u002Fh3>\u003Cp>部分亚马逊搜索结果依赖 JavaScript 渲染。当 curl_cffi 无法获取完整结果时，使用 Playwright 配合代理：\u003C\u002Fp>\u003Cpre>\u003Ccode>import asyncio\nimport re\nimport json\nimport logging\nfrom datetime import datetime\nfrom playwright.async_api import async_playwright\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(__name__)\n\nPROXY_HOST = &quot;gate.proxyhat.com&quot;\nPROXY_PORT = &quot;8080&quot;\nPROXY_USER = &quot;user-country-US-sid-{session}&quot;\nPROXY_PASS = &quot;pass&quot;\nTARGET_ASIN = &quot;B0DXXXXXXXX&quot;\nKEYWORD = &quot;bluetooth speaker&quot;\n\nasync def fetch_with_playwright(keyword: str, page_num: int, session_id: str) -&gt; str:\n    &quot;&quot;&quot;使用 Playwright 通过代理抓取搜索结果页&quot;&quot;&quot;\n    username = PROXY_USER.format(session=session_id)\n    proxy_config = {\n        &quot;server&quot;: f&quot;http:\u002F\u002F{PROXY_HOST}:{PROXY_PORT}&quot;,\n        &quot;username&quot;: username,\n        &quot;password&quot;: PROXY_PASS,\n    }\n    \n    async with async_playwright() as p:\n        browser = await p.chromium.launch(\n            headless=True,\n            proxy=proxy_config,\n            args=[&quot;--disable-blink-features=AutomationControlled&quot;]\n        )\n        context = await browser.new_context(\n            user_agent=&quot;Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36 (KHTML, like Gecko) Chrome\u002F120.0.0.0 Safari\u002F537.36&quot;,\n            locale=&quot;en-US&quot;,\n            viewport={&quot;width&quot;: 1920, &quot;height&quot;: 1080},\n        )\n        page = await context.new_page()\n        \n        url = f&quot;https:\u002F\u002Fwww.amazon.com\u002Fs?k={keyword}&amp;page={page_num}&quot;\n        try:\n            await page.goto(url, wait_until=&quot;domcontentloaded&quot;, timeout=30000)\n            await page.wait_for_selector(&apos;[data-component-type=&quot;s-search-result&quot;]&apos;, timeout=10000)\n            html = await page.content()\n            \n            # CAPTCHA 检测\n            if &quot;captcha&quot; in html.lower():\n                logger.warning(&quot;CAPTCHA detected&quot;)\n                return None\n            return html\n        except Exception as e:\n            logger.error(f&quot;Playwright error: {e}&quot;)\n            return None\n        finally:\n            await browser.close()\n\nasync def parse_playwright_html(html: str) -&gt; list[dict]:\n    &quot;&quot;&quot;解析 Playwright 渲染后的 HTML&quot;&quot;&quot;\n    results = []\n    blocks = re.findall(\n        r&apos;&lt;div[^&gt;]*data-component-type=&quot;s-search-result&quot;[^&gt;]*data-asin=&quot;([A-Z0-9]+)&quot;[^&gt;]*&gt;(.*?)(?=&lt;div[^&gt;]*data-component-type=&quot;s-search-result&quot;|&lt;\u002Fdiv&gt;\\s*&lt;\u002Fdiv&gt;\\s*&lt;\u002Fdiv&gt;)&apos;,\n        html, re.DOTALL\n    )\n    organic_pos = 0\n    for asin, block in blocks:\n        if not asin:\n            continue\n        is_sponsored = &quot;Sponsored&quot; in block\n        if not is_sponsored:\n            organic_pos += 1\n        results.append({\n            &quot;asin&quot;: asin,\n            &quot;organic_position&quot;: organic_pos if not is_sponsored else None,\n            &quot;is_sponsored&quot;: is_sponsored,\n        })\n    return results\n\nasync def main():\n    session_id = re.sub(r&apos;[^a-z0-9]&apos;, &apos;-&apos;, KEYWORD.lower())[:20]\n    all_results = []\n    \n    for pg in range(1, 6):\n        logger.info(f&quot;Playwright fetching page {pg}&quot;)\n        html = await fetch_with_playwright(KEYWORD, pg, session_id)\n        if html:\n            results = await parse_playwright_html(html)\n            all_results.extend(results)\n            await asyncio.sleep(4)\n    \n    target = next(\n        (r for r in all_results if r[&quot;asin&quot;] == TARGET_ASIN and not r[&quot;is_sponsored&quot;]),\n        None\n    )\n    print(json.dumps({\n        &quot;keyword&quot;: KEYWORD,\n        &quot;asin&quot;: TARGET_ASIN,\n        &quot;found&quot;: target is not None,\n        &quot;organic_position&quot;: target[&quot;organic_position&quot;] if target else None,\n        &quot;timestamp&quot;: datetime.utcnow().isoformat(),\n    }, indent=2))\n\nif __name__ == &quot;__main__&quot;:\n    asyncio.run(main())\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>示例 3：curl 命令行快速验证\u003C\u002Fh3>\u003Cpre>\u003Ccode># 使用 curl 通过 ProxyHat 代理抓取亚马逊搜索结果\ncurl -x &quot;http:\u002F\u002Fuser-country-US-sid-test01:pass@gate.proxyhat.com:8080&quot; \\\n  -H &quot;User-Agent: Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36&quot; \\\n  -H &quot;Accept-Language: en-US,en;q=0.9&quot; \\\n  &quot;https:\u002F\u002Fwww.amazon.com\u002Fs?k=bluetooth+speaker&amp;page=1&quot; \\\n  -o amazon_page1.html --max-time 30\n\n# 检查是否被 CAPTCHA 拦截\ngrep -i &quot;captcha&quot; amazon_page1.html\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>示例 4：批量关键词追踪（并发控制）\u003C\u002Fh3>\u003Cpre>\u003Ccode>import asyncio\nimport aiohttp\nimport json\nimport re\nimport logging\nfrom datetime import datetime\nfrom asyncio import Semaphore\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(__name__)\n\nPROXY_TEMPLATE = &quot;http:\u002F\u002Fuser-country-US-sid-{session}:pass@gate.proxyhat.com:8080&quot;\nKEYWORDS = [&quot;bluetooth speaker&quot;, &quot;wireless earbuds&quot;, &quot;phone charger&quot;, &quot;laptop stand&quot;]\nTARGET_ASIN = &quot;B0DXXXXXXXX&quot;\nMAX_CONCURRENT = 3  # 并发上限\nREQUEST_DELAY = 3  # 秒\n\nsemaphore = Semaphore(MAX_CONCURRENT)\n\nasync def fetch_keyword_rank(session: aiohttp.ClientSession, keyword: str) -&gt; dict:\n    &quot;&quot;&quot;并发追踪多个关键词的排名&quot;&quot;&quot;\n    async with semaphore:\n        session_id = re.sub(r&apos;[^a-z0-9]&apos;, &apos;-&apos;, keyword.lower())[:20]\n        proxy_url = PROXY_TEMPLATE.format(session=session_id)\n        \n        all_results = []\n        for page in range(1, 4):  # 前 3 页\n            url = f&quot;https:\u002F\u002Fwww.amazon.com\u002Fs?k={keyword}&amp;page={page}&quot;\n            headers = {\n                &quot;User-Agent&quot;: &quot;Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36&quot;,\n                &quot;Accept-Language&quot;: &quot;en-US,en;q=0.9&quot;,\n            }\n            try:\n                async with session.get(\n                    url, proxy=proxy_url, headers=headers, timeout=aiohttp.ClientTimeout(total=30)\n                ) as resp:\n                    if resp.status != 200:\n                        logger.warning(f&quot;{keyword} page {page}: HTTP {resp.status}&quot;)\n                        break\n                    html = await resp.text()\n                    if &quot;captcha&quot; in html.lower():\n                        logger.warning(f&quot;CAPTCHA for &apos;{keyword}&apos; page {page}&quot;)\n                        break\n                    # 简化解析\n                    asins = re.findall(r&apos;data-asin=&quot;([A-Z0-9]{10})&quot;&apos;, html)\n                    all_results.extend(asins)\n            except Exception as e:\n                logger.error(f&quot;Error fetching &apos;{keyword}&apos; page {page}: {e}&quot;)\n                break\n            await asyncio.sleep(REQUEST_DELAY)\n        \n        # 查找目标 ASIN 的位置\n        position = None\n        for i, asin in enumerate(all_results, 1):\n            if asin == TARGET_ASIN:\n                position = i\n                break\n        \n        return {\n            &quot;keyword&quot;: keyword,\n            &quot;asin&quot;: TARGET_ASIN,\n            &quot;found&quot;: position is not None,\n            &quot;position&quot;: position,\n            &quot;timestamp&quot;: datetime.utcnow().isoformat(),\n        }\n\nasync def main():\n    async with aiohttp.ClientSession() as session:\n        tasks = [fetch_keyword_rank(session, kw) for kw in KEYWORDS]\n        results = await asyncio.gather(*tasks)\n        \n    for r in results:\n        print(json.dumps(r, indent=2))\n        with open(f&quot;rank_history_{TARGET_ASIN}.jsonl&quot;, &quot;a&quot;) as f:\n            f.write(json.dumps(r) + &quot;\\n&quot;)\n\nif __name__ == &quot;__main__&quot;:\n    asyncio.run(main())\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>示例 5：SOCKS5 代理 + 重试与断路器\u003C\u002Fh3>\u003Cpre>\u003Ccode>import requests\nimport time\nimport json\nimport logging\nfrom datetime import datetime\nfrom circuitbreaker import circuit  # pip install circuitbreaker\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(__name__)\n\nSOCKS5_PROXY = &quot;socks5:\u002F\u002Fuser-country-US-sid-rank01:pass@gate.proxyhat.com:1080&quot;\nTARGET_ASIN = &quot;B0DXXXXXXXX&quot;\n\nclass AmazonRankTracker:\n    &quot;&quot;&quot;带断路器保护的亚马逊排名追踪器&quot;&quot;&quot;\n    \n    def __init__(self, proxy: str, max_retries: int = 3):\n        self.proxy = proxy\n        self.max_retries = max_retries\n        self.session = requests.Session()\n        self.session.proxies = {&quot;http&quot;: proxy, &quot;https&quot;: proxy}\n        self.session.headers.update({\n            &quot;User-Agent&quot;: &quot;Mozilla\u002F5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\u002F537.36&quot;,\n            &quot;Accept-Language&quot;: &quot;en-US,en;q=0.9&quot;,\n        })\n    \n    @circuit(failure_threshold=5, recovery_timeout=60)\n    def fetch_page(self, keyword: str, page: int) -&gt; str:\n        &quot;&quot;&quot;带断路器保护的页面抓取&quot;&quot;&quot;\n        url = f&quot;https:\u002F\u002Fwww.amazon.com\u002Fs?k={keyword}&amp;page={page}&quot;\n        \n        for attempt in range(self.max_retries):\n            try:\n                resp = self.session.get(url, timeout=30)\n                if resp.status_code == 200:\n                    if &quot;captcha&quot; in resp.text.lower():\n                        raise Exception(&quot;CAPTCHA detected&quot;)\n                    return resp.text\n                elif resp.status_code == 503:\n                    wait = 2 ** attempt\n                    logger.warning(f&quot;503, waiting {wait}s before retry&quot;)\n                    time.sleep(wait)\n                else:\n                    raise Exception(f&quot;HTTP {resp.status_code}&quot;)\n            except Exception as e:\n                logger.error(f&quot;Attempt {attempt+1} failed: {e}&quot;)\n                if attempt &lt; self.max_retries - 1:\n                    time.sleep(2 ** attempt)\n                else:\n                    raise\n        raise Exception(&quot;Max retries exceeded&quot;)\n    \n    def check_indexation(self, keyword: str, asin: str, max_pages: int = 5) -&gt; dict:\n        &quot;&quot;&quot;检查 ASIN 是否被索引（是否出现在搜索结果中）&quot;&quot;&quot;\n        for page in range(1, max_pages + 1):\n            try:\n                html = self.fetch_page(keyword, page)\n                if asin in html:\n                    return {\n                        &quot;indexed&quot;: True,\n                        &quot;keyword&quot;: keyword,\n                        &quot;asin&quot;: asin,\n                        &quot;page_found&quot;: page,\n                        &quot;timestamp&quot;: datetime.utcnow().isoformat(),\n                    }\n            except Exception as e:\n                logger.error(f&quot;Indexation check failed on page {page}: {e}&quot;)\n                break\n            time.sleep(3)\n        \n        return {\n            &quot;indexed&quot;: False,\n            &quot;keyword&quot;: keyword,\n            &quot;asin&quot;: asin,\n            &quot;timestamp&quot;: datetime.utcnow().isoformat(),\n        }\n\n# 使用示例\ntracker = AmazonRankTracker(SOCKS5_PROXY)\nresult = tracker.check_indexation(&quot;bluetooth speaker&quot;, TARGET_ASIN)\nprint(json.dumps(result, indent=2))\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch2>常见错误与边界情况\u003C\u002Fh2>\u003Ch3>1. 未分离广告位与自然位\u003C\u002Fh3>\u003Cp>亚马逊搜索结果页顶部和中间穿插广告位。如果不区分 \"Sponsored\" 标签，你的排名数据会将广告位计入自然排名，导致数据失真。务必在解析时检测广告标记并单独计数。\u003C\u002Fp>\u003Ch3>2. 翻页时 IP 变化导致结果不一致\u003C\u002Fh3>\u003Cp>如果翻页时代理 IP 发生变化，亚马逊可能返回不同的搜索结果集——尤其是排名 40-60 以后的商品。使用粘性会话（\u003Ccode>-sid-\u003C\u002Fcode>）确保同一关键词的所有页面请求来自同一 IP。\u003C\u002Fp>\u003Ch3>3. 忽略 CAPTCHA 信号\u003C\u002Fh3>\u003Cp>亚马逊在检测到可疑流量时会返回 CAPTCHA 页面而非搜索结果。如果解析代码未检测 CAPTCHA，会将 CAPTCHA 页面的内容误解析为空结果，导致「ASIN 未排名」的错误结论。务必在解析前检查 HTML 中是否包含 \"captcha\" 或 \"robot\" 关键词。\u003C\u002Fp>\u003Ch3>4. 请求频率过高\u003C\u002Fh3>\u003Cp>即使使用住宅代理，短时间内大量请求仍会触发封禁。建议每个关键词的页面请求间隔 3-5 秒，并发数不超过 3-5 个关键词。对于大规模追踪（100+ 关键词），考虑分批执行，每批之间间隔 10-15 分钟。\u003C\u002Fp>\u003Ch3>5. 未做索引检查\u003C\u002Fh3>\u003Cp>如果 ASIN 根本没有被亚马逊索引（即不出现在任何搜索结果中），排名追踪无意义。在开始追踪前，先做一次索引检查——搜索关键词的前 5 页是否包含目标 ASIN。如果未找到，可能需要检查产品 listing 状态或关键词相关性。\u003C\u002Fp>\u003Ch2>生产级实践建议\u003C\u002Fh2>\u003Ch3>每日定时调度\u003C\u002Fh3>\u003Cpre>\u003Ccode># 使用 cron 每天凌晨 2 点运行排名追踪\n# crontab -e\n0 2 * * * \u002Fusr\u002Fbin\u002Fpython3 \u002Fpath\u002Fto\u002Famazon_rank_tracker.py &gt;&gt; \u002Fvar\u002Flog\u002Frank_tracker.log 2&gt;&amp;1\u003C\u002Fcode>\u003C\u002Fpre>\u003Ch3>数据存储与历史趋势\u003C\u002Fh3>\u003Cp>将每日排名数据以 JSONL 格式追加到文件或写入数据库（SQLite\u002FPostgreSQL），便于后续分析排名趋势。关键字段包括：\u003Ccode>timestamp\u003C\u002Fcode>、\u003Ccode>keyword\u003C\u002Fcode>、\u003Ccode>asin\u003C\u002Fcode>、\u003Ccode>marketplace\u003C\u002Fcode>、\u003Ccode>organic_position\u003C\u002Fcode>、\u003Ccode>page\u003C\u002Fcode>。\u003C\u002Fp>\u003Ch3>重试与退避策略\u003C\u002Fh3>\u003Cp>实现指数退避重试：首次失败等待 2 秒，第二次 4 秒，第三次 8 秒。连续失败 5 次后触发断路器，暂停 60 秒。这避免了在亚马逊临时限流时持续重试导致更严重的封禁。\u003C\u002Fp>\u003Ch3>多市场并行追踪\u003C\u002Fh3>\u003Cp>如果卖家在多个亚马逊站点销售（如 amazon.com + amazon.de + amazon.co.uk），使用不同国家地理定位的代理分别追踪。每个市场使用独立的会话 ID 命名空间，避免会话冲突。\u003C\u002Fp>\u003Ch2>合规与伦理考量\u003C\u002Fh2>\u003Cp>排名追踪应遵循以下原则：\u003C\u002Fp>\u003Cul>\u003Cli>只追踪公开数据和自有商品：搜索结果页是公开可见的，但大量自动化请求可能违反亚马逊 ToS。优先考虑 \u003Ca href=\"https:\u002F\u002Fdeveloper-docs.amazon\u002Fsp-api\u002F\" rel=\"noopener noreferrer\">Amazon SP-API\u003C\u002Fa> 获取合规的产品目录和报告数据。\u003C\u002Fli>\u003Cli>控制请求频率：合理限速，避免对亚马逊服务器造成压力。每个关键词间隔 3-5 秒是合理基准。\u003C\u002Fli>\u003Cli>遵守 robots.txt：检查 \u003Ca href=\"https:\u002F\u002Fwww.amazon.com\u002Frobots.txt\" rel=\"noopener noreferrer\">amazon.com\u002Frobots.txt\u003C\u002Fa> 了解允许抓取的路径。\u003C\u002Fli>\u003Cli>遵守 CFAA 和 GDPR：在美国，CFAA 禁止「未经授权」访问计算机系统；在欧盟，GDPR 保护个人数据。搜索结果中的卖家信息可能涉及个人数据，采集时需谨慎。\u003C\u002Fli>\u003Cli>考虑 SP-API 替代方案：Amazon SP-API 提供了合规的 \u003Ca href=\"https:\u002F\u002Fdeveloper-docs.amazon\u002Fsp-api\u002Fpage\u002F404\" rel=\"noopener noreferrer\">Catalog Items API\u003C\u002Fa> 和产品报告接口，对于自有商品的排名和销量数据，SP-API 是首选。\u003C\u002Fli>\u003C\u002Ful>\u003Cp>准备好搭建你的亚马逊关键词排名追踪系统了吗？查看 \u003Ca href=\"\u002Fcn\u002Fpricing\">ProxyHat 定价方案\u003C\u002Fa>选择适合的住宅代理套餐，或访问 \u003Ca href=\"\u002Fcn\u002Fuse-cases\u002Fserp-tracking\">SERP 追踪用例\u003C\u002Fa>了解更多应用场景。如需了解代理覆盖的地理位置，请查看 \u003Ca href=\"\u002Fcn\u002Flocations\">代理位置列表\u003C\u002Fa>。更多 Web 采集技巧请参考 \u003Ca href=\"\u002Fcn\u002Fuse-cases\u002Fweb-scraping\">Web 采集用例\u003C\u002Fa>。\u003C\u002Fp>","使用代理追踪亚马逊关键词排名完整指南 | ProxyHat","学习使用代理追踪亚马逊关键词排名：解析搜索结果页、分离广告与自然位、住宅代理地理定位、Python 代码示例与生产级技巧。","\u002Fcn\u002Fblog\u002Famazon-guanjianci-paiming-zhuizong-daili-1",null,"面向亚马逊卖家的关键词排名追踪指南——住宅代理、Python 代码示例、生产级重试与合规注意事项。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Famazon-guanjianci-paiming-zhuizong-daili-1-og.webp",[18,21],{"question":19,"answer":20},"为什么代理用户需要使用代理追踪亚马逊关键词排名？","亚马逊搜索结果高度本地化——不同国家、邮编甚至设备返回的排名不同。直接从单一 IP 大量请求会触发 CAPTCHA 和 IP 封禁。住宅代理提供真实住宅 IP，配合国家级地理定位（如 -country-US、-country-DE）可以准确获取目标市场的排名数据，同时降低被封风险。",{"question":22,"answer":23},"如何在实现亚马逊关键词排名追踪时避免被封？","关键策略包括：使用住宅代理配合国家地理定位、控制请求频率（每个关键词间隔 3-5 秒）、使用粘性会话保持翻页一致性、检测并处理 CAPTCHA 页面、实现指数退避重试机制、轮换 User-Agent 和浏览器指纹、以及优先考虑 Amazon SP-API 获取合规数据。只追踪公开搜索数据和自有商品列表。",[25,26,27,28,29],"追踪亚马逊关键词排名需使用住宅代理，以获取准确的地理位置数据并有效规避反爬机制。","翻页抓取时必须使用粘性会话保持同一IP，避免因IP切换导致排名数据产生偏差。","解析搜索结果页时，可通过data-asin属性提取ASIN，并检测Sponsored文本区分自然位与广告位。","代码实现需具备容错能力，遇到CAPTCHA或选择器失效时应记录错误并退避重试，避免直接崩溃。","数据中心IP极易被亚马逊封禁，因此住宅代理是进行关键词排名追踪的首选方案。",false,"2026-07-16T16:05:31+00:00","2026-10-03T08:21:23+00:00","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Famazon-guanjianci-paiming-zhuizong-daili-1-master.webp","Amazon Keyword Rank Tracking with Proxies: A Developer's Guide","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Famazon-guanjianci-paiming-zhuizong-daili-1-card.webp",13,{"name":38,"slug":39,"bio":40,"avatar_url":14,"website_url":14,"social_links":14},"ProxyHat Team","proxyhat-team","The ProxyHat editorial team covers proxies, web scraping, and data extraction.",[42],{"id":43,"slug":44,"name":45,"description":14,"meta_title":46,"meta_description":47,"parent_id":14},3,"serp-he-seo","SERP与SEO追踪","SERP与SEO追踪指南 | ProxyHat 博客","如何使用代理追踪搜索引擎排名和抓取SERP数据。",[],{"tr":50,"it":51,"en":52,"x-default":52},"\u002Ftr\u002Fblog\u002Fproxy-ile-amazon-anahtar-kelime-siralama-takibi","\u002Fit\u002Fblog\u002Fmonitoraggio-posizionamento-keyword-amazon-proxy","\u002Fblog\u002Famazon-keyword-rank-tracking-proxies-1",{"tr":50,"pl":54,"es":55,"pt":56,"ja":57,"zh":13,"de":58,"ko":59,"it":51,"ru":60,"en":52,"fr":61},"\u002Fpl\u002Fblog\u002Fsledzenie-rankingu-slow-kluczowych-amazon-proxy","\u002Fes\u002Fblog\u002Fseguimiento-ranking-palabras-clave-amazon-proxies","\u002Fpt\u002Fblog\u002Frastreamento-ranking-palavras-chave-amazon-proxies","\u002Fja\u002Fblog\u002Famazon-keyword-rank-tracking-proxy-1","\u002Fde\u002Fblog\u002Famazon-keyword-rank-tracking-mit-proxies","\u002Fko\u002Fblog\u002Famazon-keyword-rank-tracker-proxy-guide","\u002Fru\u002Fblog\u002Famazon-treking-pozitsiy-klyuchevyh-slov","\u002Ffr\u002Fblog\u002Fsuivi-classement-amazon-proxy-python",117,[64,81,97,114],{"id":65,"slug":66,"title":67,"excerpt":68,"featured_image_url":69,"featured_image_alt":70,"card_image_url":71,"og_image_url":72,"published_at":73,"updated_at":73,"content_updated_at":74,"reading_time_minutes":75,"is_featured":30,"indexable":30,"views":76,"author":77,"categories":78,"tags":80},198,"serp-dili-dingwei-zhuaqu-zhinan","地理定位SERP抓取最佳实践：从uule到城市级代理的完整指南","掌握地理定位SERP抓取的核心参数uule\u002Fgl\u002Fhl\u002Fgoogle_domain，配合城市级住宅代理实现精确的本地SEO排名追踪。包含完整Python代码示例与生产级重试策略。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fserp-dili-dingwei-zhuaqu-zhinan-master.webp","Geo-Targeted SERP Scraping Best Practices for Local SEO Data","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fserp-dili-dingwei-zhuaqu-zhinan-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fserp-dili-dingwei-zhuaqu-zhinan-og.webp","2026-07-31T16:11:16+00:00","2026-11-17T09:21:33+00:00",12,77,{"name":38,"slug":39,"bio":40,"avatar_url":14,"website_url":14,"social_links":14},[79],{"id":43,"slug":44,"name":45,"description":14,"meta_title":46,"meta_description":47,"parent_id":14},[],{"id":82,"slug":83,"title":84,"excerpt":85,"featured_image_url":86,"featured_image_alt":87,"card_image_url":88,"og_image_url":89,"published_at":90,"updated_at":90,"content_updated_at":91,"reading_time_minutes":75,"is_featured":30,"indexable":30,"views":92,"author":93,"categories":94,"tags":96},153,"zhuaqu-google-paa-zidongbuchquan-guanjianci","抓取Google People Also Ask与自动补全做关键词研究：Python实战指南","本指南教你用Python抓取Google自动补全、People Also Ask和相关搜索三大关键词金矿，结合ProxyHat住宅代理实现地理定位与防封锁，构建从种子词到长尾词的自动化扩展流程。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fzhuaqu-google-paa-zidongbuchquan-guanjianci-master.webp","Scrape Google People Also Ask and Autocomplete for Keyword Research (Python Guide)","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fzhuaqu-google-paa-zidongbuchquan-guanjianci-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fzhuaqu-google-paa-zidongbuchquan-guanjianci-og.webp","2026-07-14T16:06:25+00:00","2026-10-03T23:53:01+00:00",152,{"name":38,"slug":39,"bio":40,"avatar_url":14,"website_url":14,"social_links":14},[95],{"id":43,"slug":44,"name":45,"description":14,"meta_title":46,"meta_description":47,"parent_id":14},[],{"id":98,"slug":99,"title":100,"excerpt":101,"featured_image_url":102,"featured_image_alt":103,"card_image_url":104,"og_image_url":105,"published_at":106,"updated_at":106,"content_updated_at":107,"reading_time_minutes":108,"is_featured":30,"indexable":30,"views":109,"author":110,"categories":111,"tags":113},154,"zhui-zong-google-ai-gailan-pinpai","如何追踪Google AI Overviews中的品牌表现：生成式搜索时代的可见性测量框架","Google AI Overviews已覆盖约36%的信息类查询，传统蓝链点击被压缩，引用份额成为新的排名KPI。本文为SEO负责人和数据PM提供一套从数据采集到ROI计算的AI搜索可见性追踪框架。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fzhui-zong-google-ai-gailan-pinpai-master.webp","How to Track Your Brand in Google AI Overviews: A Strategic Guide for SEO & Data Teams","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fzhui-zong-google-ai-gailan-pinpai-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fzhui-zong-google-ai-gailan-pinpai-og.webp","2026-07-14T10:05:37+00:00","2026-10-03T23:53:00+00:00",10,80,{"name":38,"slug":39,"bio":40,"avatar_url":14,"website_url":14,"social_links":14},[112],{"id":43,"slug":44,"name":45,"description":14,"meta_title":46,"meta_description":47,"parent_id":14},[],{"id":92,"slug":115,"title":116,"excerpt":117,"featured_image_url":118,"featured_image_alt":119,"card_image_url":120,"og_image_url":121,"published_at":122,"updated_at":122,"content_updated_at":107,"reading_time_minutes":75,"is_featured":30,"indexable":30,"views":123,"author":124,"categories":125,"tags":127},"python-google-paiming-zhuizong","使用住宅代理在Python中构建Google排名追踪器：完整代码指南","本指南面向SEO工程师和Python开发者，演示如何用curl_cffi和ProxyHat住宅代理构建生产级Google排名追踪器，涵盖数据模型、SERP分页抓取、TLS指纹规避、重试策略与并发控制。","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fpython-google-paiming-zhuizong-master.webp","Build a Google Rank Tracker in Python with Residential Proxies","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fpython-google-paiming-zhuizong-card.webp","https:\u002F\u002Fstatic.proxyhat.com\u002Fstorage\u002Fblog-covers\u002Fzh\u002Fpython-google-paiming-zhuizong-og.webp","2026-07-02T16:04:58+00:00",58,{"name":38,"slug":39,"bio":40,"avatar_url":14,"website_url":14,"social_links":14},[126],{"id":43,"slug":44,"name":45,"description":14,"meta_title":46,"meta_description":47,"parent_id":14},[],[]]