# Map

> 输入网站即可极快获取其所有 URL

import InstallationPython from "/snippets/zh/v2/installation/python.mdx";
import InstallationJavaScript from "/snippets/zh/v2/installation/js.mdx";
import InstallationCLI from "/snippets/zh/v2/installation/cli.mdx";
import MapPython from "/snippets/zh/v2/map/base/python.mdx";
import MapJavaScript from "/snippets/zh/v2/map/base/js.mdx";
import MapCURL from "/snippets/zh/v2/map/base/curl.mdx";
import MapCLI from "/snippets/zh/v2/map/base/cli.mdx";
import MapResponse from "/snippets/zh/v2/map/base/output.mdx";
import MapLocationPython from "/snippets/zh/v2/map/location/python.mdx";
import MapLocationNode from "/snippets/zh/v2/map/location/js.mdx";
import MapLocationCURL from "/snippets/zh/v2/map/location/curl.mdx";
import PlaygroundCTA from "/snippets/zh/shared/playground-cta-map.mdx";

<div id="introducing-map">
  ## 介绍 /map
</div>

从单个 URL 快速生成整站链接地图的最简方式。这在以下场景特别有用：

* 需要让终端用户选择要抓取的链接时
* 需要快速了解网站包含哪些链接
* 需要抓取与特定主题相关的页面 (使用 `search` 参数) 
* 只需抓取网站中的特定页面

<PlaygroundCTA />

<div id="mapping">
  ## 映射
</div>

<div id="map-endpoint">
  ### /map 端点
</div>

用于映射一个 URL 并获取该网站的 URL。会返回站点上大部分的链接。

URL 主要从网站的 sitemap 中获取，并辅以 SERP (搜索引擎结果页) 结果和之前抓取的页面，以提升覆盖率。你可以使用 `sitemap` 参数来控制 sitemap 的行为。

<div id="installation">
  ### 安装
</div>

<CodeGroup>
  <InstallationPython />

  <InstallationJavaScript />

  <InstallationCLI />
</CodeGroup>

<div id="usage">
  ### 使用方法
</div>

<CodeGroup>
  <MapPython />

  <MapJavaScript />

  <MapCURL />

  <MapCLI />
</CodeGroup>

<Info>
  每次 map 请求都会消耗 1 个 credit，与返回的 URL 数量无关。例如，即使将 `limit` 设置为 100,000，也只会使用 1 个 credit。
</Info>

<div id="response">
  ### 响应
</div>

SDK 会直接返回数据对象。cURL 会按下方所示原样返回负载。

<MapResponse />

<Warning>
  标题和描述不一定都会提供，具体取决于网站。
</Warning>

<div id="map-with-search">
  #### 带搜索参数的 Map
</div>

使用 `search` 参数的 Map 可在站内搜索特定的 URL。

```bash cURL
curl -X POST https://api.firecrawl.dev/v2/map \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
    "url": "https://firecrawl.dev",
    "search": "docs"
  }'
```

响应将按相关性从高到低返回一个有序列表。

```json
{
  "status": "success",
  "links": [
    {
      "url": "https://docs.firecrawl.dev",
      "title": "Firecrawl 文档",
      "description": "Firecrawl 文档"
    },
    {
      "url": "https://docs.firecrawl.dev/sdks/python",
      "title": "Firecrawl Python SDK",
      "description": "Firecrawl Python SDK 文档"
    },
    ...
  ]
}
```

<div id="location-and-language">
  ## 位置与语言
</div>

指定国家和首选语言，根据你的目标位置与语言偏好获取更相关的内容，方式与 /scrape 端点相似。

<div id="how-it-works">
  ### 工作原理
</div>

当你指定位置设置时，Firecrawl 会在可用时使用合适的代理，并模拟相应的语言和时区设置。默认情况下，若未指定，位置将设为“US”。

<div id="usage-2">
  ### 用法
</div>

要配置位置和语言，请在请求体中包含 `location` 对象，并设置以下属性：

* `country`：ISO 3166-1 alpha-2 国家代码 (如 &#39;US&#39;、&#39;AU&#39;、&#39;DE&#39;、&#39;JP&#39;) 。默认值为 &#39;US&#39;。
* `languages`：按优先级排序的首选语言与区域设置数组。默认使用所设位置的语言。

<CodeGroup>
  <MapLocationPython />

  <MapLocationNode />

  <MapLocationCURL />
</CodeGroup>

有关支持的地区与位置的更多信息，请参见 [Proxies 文档](/zh/features/proxies)。

<div id="considerations">
  ## 注意事项
</div>

该端点优先考虑速度，因此可能无法捕获所有网站链接。它主要依赖网站的 sitemap，并结合缓存的爬取数据和搜索引擎结果。若需要更全面且最新的 URL 列表，请考虑改用 [/crawl](/zh/features/crawl) 端点。

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