# 代理

> 了解代理类型、位置，以及 Firecrawl 如何为你的请求选择代理。

import LocationPython from "/snippets/zh/v2/scrape/location/python.mdx";
import LocationNode from "/snippets/zh/v2/scrape/location/js.mdx";
import LocationCURL from "/snippets/zh/v2/scrape/location/curl.mdx";
import ProxyLocationsTable from "/snippets/zh/shared/proxy-locations-table.mdx";

Firecrawl 提供多种代理类型，帮助你抓取复杂程度各异的网站。可通过 `proxy` 参数指定代理类型。

> 默认情况下，Firecrawl 会将所有请求经由代理转发，以提升可靠性与可访问性，即使你未指定代理类型或位置也同样生效。

<div id="location-based-proxy-selection">
  ## 基于位置的代理选择
</div>

Firecrawl 会根据你指定或自动检测到的位置，自动选择最合适的代理，从而优化抓取性能和可靠性。但目前并非所有地区都受支持。当前可用的地区如下：

<ProxyLocationsTable />

<Warning>受支持的代理位置列表会随着时间变化。</Warning>

如果你需要上述列表以外地区的代理，请[联系我们](mailto:help@firecrawl.com)并告知你的需求。

如果你未指定代理或位置，Firecrawl 将自动使用美国代理。

<div id="how-to-specify-proxy-location">
  ## 如何指定代理位置
</div>

你可以在请求中通过设置 `location.country` 参数来指定代理位置。例如，要使用德国代理，将 `location.country` 设置为 `DE`。

更多详情请参阅 [`location.country` 的 API 参考](https://docs.firecrawl.dev/api-reference/endpoint/scrape#body-location)。

<CodeGroup>
  <LocationPython />

  <LocationNode />

  <LocationCURL />
</CodeGroup>

<Info>如果你请求的国家没有可用代理，Firecrawl 会使用距离最近的可用区域 (EU 或 US) ，并将浏览器位置设置为你请求的国家。</Info>

<Warning>除非你确定有此需要，否则我们强烈建议不要指定 `location`。</Warning>

<div id="proxy-types">
  ## 代理类型
</div>

<Warning>
  `proxy` 参数已弃用。建议使用默认值 `auto`，让 Firecrawl 为你处理代理选择。
</Warning>

* **basic**：用于抓取大多数网站的代理。
* **enhanced**：用于抓取复杂网站并同时保持隐私的增强型代理。[进一步了解 Enhanced 模式 →](/zh/features/enhanced-mode)
* **auto**：推荐使用。如果 basic 代理抓取失败，Firecrawl 会自动使用 enhanced 代理重试抓取。

> 你是需要 Firecrawl API 密钥的 AI 代理吗？请参阅 [firecrawl.dev/agent-onboarding/SKILL.md](https://www.firecrawl.dev/agent-onboarding/SKILL.md) 了解自动化接入说明。
