> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl.web3doc.top/llms.txt
> Use this file to discover all available pages before exploring further.

# 发布周II（新功能）

> 查看发布周II（10月28日 - 11月3日）期间Firecrawl的新功能

## 第七天 - 更快的 Markdown 解析

我们从头开始重建了我们的 Markdown 解析器，专注于速度和性能。这一增强确保您的网络抓取任务更加高效，并提供更高质量的结果。

### 新功能？

* **速度提升**：体验解析速度比之前快 4 倍，允许快速数据处理并减少等待时间。
* **增强的可靠性**：我们的新解析器能够更优雅地处理更广泛的 HTML 内容，减少错误并提高一致性。
* **更干净的 Markdown 输出**：获取更干净、更易读的 Markdown，使您的数据更容易使用并集成到工作流程中。

## 第六天 - 移动设备抓取（+ 移动截图）

Firecrawl 现在引入了**移动设备模拟**，用于抓取和截图，使您能够像从移动设备那样与网站互动。此功能对于测试特定于移动的内容、理解响应式设计和从特定于移动的元素中获得洞察至关重要。

### 为什么需要移动设备抓取？

移动优先的体验越来越普遍，这个功能使您能够：

* 拍摄高保真的移动截图，以更准确地展示网站在移动设备上的外观。
* 测试和验证移动布局和 UI 元素，确保对响应式网站的抓取结果的准确性。
* 抓取仅在移动设备上的内容，访问与桌面版本不同的信息或布局。

### 使用方法

要激活移动抓取，只需在请求中添加`"mobile": true`，这将启用 Firecrawl 的移动模拟模式。

<CodeGroup>
  ```python Python theme={null}
  from firecrawl import FirecrawlApp

  app = FirecrawlApp(api_key="fc-YOUR_API_KEY")

  # 抓取一个网站:
  scrape_result = app.scrape_url('google.com',
      params={
          'formats': ['markdown', 'html'],
          'mobile': true
      }
  )
  print(scrape_result)
  ```

  ```js Node theme={null}
  import FirecrawlApp, { ScrapeResponse } from '@mendable/firecrawl-js';

  const app = new FirecrawlApp({apiKey: "fc-YOUR_API_KEY"});

  // 抓取网站内容：
  const scrapeResult = await app.scrapeUrl('google.com', { formats: ['markdown', 'html'], mobile: true }) as ScrapeResponse;

  if (!scrapeResult.success) {
    throw new Error(`抓取失败: ${scrapeResult.error}`)
  }

  console.log(scrapeResult);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.firecrawl.dev/v1/scrape \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -d '{
          "url": "google.com",
          "formats": ["markdown"],
          "mobile": true
      }'
  ```
</CodeGroup>

有关更多详细信息，包括其他配置选项，请访问[API 参考](https://docs.firecrawl.dev/api-reference/endpoint/scrape)。

## 第五天 - 操作（新增 2 个操作）

Firecrawl 允许您在抓取网页内容之前执行各种操作。这对于与动态内容交互、导航页面或访问需要用户交互的内容特别有用。

我们很高兴介绍两个强大的新操作：

1. **抓取**：在交互序列的任何点捕获当前页面内容，返回 URL 和 HTML。
2. **等待选择器**：在继续之前等待页面上出现特定元素，确保更可靠的自动化。

```json theme={null}
actions = [
    {"type": "scrape"},
    {"type": "wait", "selector": "#my-element"},
]
```

这里有一个示例，说明如何使用操作导航到 google.com，搜索 Firecrawl，点击第一个结果，抓取当前页面内容并截图。

为了更精确的控制，您可以现在使用`{type: "wait", selector: "#my-element"}`来等待页面上出现特定元素。

### 示例

<CodeGroup>
  ```python Python theme={null}
  from firecrawl import FirecrawlApp

  app = FirecrawlApp(api_key="fc-YOUR_API_KEY")

  # 抓取一个网站:
  scrape_result = app.scrape_url('firecrawl.dev',
      params={
          'formats': ['markdown', 'html'],
          'actions': [
              {"type": "wait", "milliseconds": 2000},
              {"type": "click", "selector": "textarea[title=\"Search\"]"},
              {"type": "wait", "milliseconds": 2000},
              {"type": "write", "text": "firecrawl"},
              {"type": "wait", "milliseconds": 2000},
              {"type": "press", "key": "ENTER"},
              {"type": "wait", "milliseconds": 3000},
              {"type": "click", "selector": "h3"},
              {"type": "wait", "milliseconds": 3000},
              {"type": "scrape"},
              {"type": "screenshot"}
          ]
      }
  )
  print(scrape_result)
  ```

  ```js Node theme={null}
  import FirecrawlApp, { ScrapeResponse } from '@mendable/firecrawl-js';

  const app = new FirecrawlApp({apiKey: "fc-YOUR_API_KEY"});

  // 抓取一个网站：
  const scrapeResult = await app.scrapeUrl('firecrawl.dev', { formats: ['markdown', 'html'], actions: [
      { type: "wait", milliseconds: 2000 },
      { type: "click", selector: "textarea[title=\"Search\"]" },
      { type: "wait", milliseconds: 2000 },
      { type: "write", text: "firecrawl" },
      { type: "wait", milliseconds: 2000 },
      { type: "press", key: "ENTER" },
      { type: "wait", milliseconds: 3000 },
      { type: "click", selector: "h3" },
      { type: "scrape" },
      {"type": "screenshot"}
  ] }) as ScrapeResponse;

  if (!scrapeResult.success) {
    throw new Error(`抓取失败: ${scrapeResult.error}`)
  }

  console.log(scrapeResult)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.firecrawl.dev/v1/scrape \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -d '{
          "url": "google.com",
          "formats": ["markdown"],
          "actions": [
              {"type": "wait", "milliseconds": 2000},
              {"type": "click", "selector": "textarea[title=\"Search\"]"},
              {"type": "wait", "milliseconds": 2000},
              {"type": "write", "text": "firecrawl"},
              {"type": "wait", "milliseconds": 2000},
              {"type": "press", "key": "ENTER"},
              {"type": "wait", "milliseconds": 3000},
              {"type": "click", "selector": "h3"},
              {"type": "wait", "milliseconds": 3000},
              {"type": "screenshot"}
          ]
      }'
  ```
</CodeGroup>

### 输出

<CodeGroup>
  ```json JSON theme={null}
  {
    "success": true,
    "data": {
      "markdown": "我们的首次Launch Week已经结束！[查看回顾 🚀](blog/firecrawl-launch-week-1-recap)...",
      "actions": {
        "screenshots": [
          "https://alttmdsdujxrfnakrkyi.supabase.co/storage/v1/object/public/media/screenshot-75ef2d87-31e0-4349-a478-fb432a29e241.png"
        ],
        "scrapes": [
          {
            "url": "https://www.firecrawl.dev/",
            "html": "<html><body><h1>Firecrawl</h1></body></html>"
          }
        ]
      },
      "metadata": {
        "title": "Home - Firecrawl",
        "description": "Firecrawl爬取并将任何网站转换为干净的Markdown。",
        "language": "en",
        "keywords": "Firecrawl, Markdown, Data, Mendable, Langchain",
        "robots": "follow, index",
        "ogTitle": "Firecrawl",
        "ogDescription": "将任何网站转换为LLM准备好的数据。",
        "ogUrl": "https://www.firecrawl.dev/",
        "ogImage": "https://www.firecrawl.dev/og.png?123",
        "ogLocaleAlternate": [],
        "ogSiteName": "Firecrawl",
        "sourceURL": "http://google.com",
        "statusCode": 200
      }
    }
  }
  ```
</CodeGroup>

有关操作参数的更多详细信息，请参阅[API参考](https://docs.firecrawl.dev/api-reference/endpoint/scrape)。

## 第四天 - 高级 iframe 抓取

我们很高兴宣布 Firecrawl 全面支持 iframe 抓取。我们的抓取器现在可以无缝处理嵌套的 iframe、动态加载的内容和跨域框架——解决了网络抓取最具挑战性的技术难题之一。

### 技术革新

Firecrawl 现在实现了：

* 递归 iframe 遍历和内容提取
* 跨域 iframe 处理，带有适当的安全上下文管理
* 智能自动等待 iframe 内容加载
* 支持动态注入的 iframe
* 正确处理沙箱 iframe

### 为什么重要

许多现代网站使用 iframe 用于：

* 嵌入内容和小部件
* 支付表单和安全输入
* 第三方集成
* 广告框架
* 社交媒体嵌入

以前，这些元素在抓取结果中常常是黑盒子。现在，您可以完全访问 iframe 内容，就像访问页面的其他部分一样。

### 使用方法

无需额外配置！当您使用我们的任何抓取或爬取端点时，iframe 抓取会自动发生。无论您是使用`/scrape`进行单页抓取还是使用`/crawl`进行整个网站的爬取，iframe 内容都将无缝集成到您的结果中。

## 第三天 - 信用包

信用包允许您轻松地为您的计划充值，如果您的余额不足。此外，我们现在提供自动充值功能，当您的余额接近限额时自动为您的账户充值。要启用，请访问定价页面[https://www.firecrawl.dev/pricing](https://www.firecrawl.dev/pricing)。

### 信用包

灵活的每月信用增长为您的项目。

* **9 美元/月，1000 信用**
* 添加到任何现有计划
* 选择您需要的金额

### 自动充值信用

在信用不足时自动为您的账户充值。

* **每 1000 信用 11 美元**
* 使用任何订阅计划启用自动充值

## 第二天 - 地理位置

为抓取请求引入位置和语言设置。指定国家和首选语言，根据目标位置和语言偏好获取相关内容。

### 工作原理

当您指定位置设置时，Firecrawl 将使用适当的代理（如果有），并模拟相应的语言和时区设置。默认情况下，如果未指定，位置设置为'US'。

### 使用方法

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

* `country`：ISO 3166-1 alpha-2 国家代码（例如，'US'，'AU'，'DE'，'JP'）。默认为'US'。
* `languages`：按优先级顺序排列的首选语言和地区数组。默认值为指定位置的语言。

<CodeGroup>
  ```python Python theme={null}
  from firecrawl import FirecrawlApp

  app = FirecrawlApp(api_key="fc-YOUR_API_KEY")

  # 抓取一个网站:
  scrape_result = app.scrape_url('airbnb.com',
      params={
          'formats': ['markdown', 'html'],
          'location': {
              'country': 'BR',
              'languages': ['pt-BR']
          }
      }
  )
  print(scrape_result)
  ```

  ```js Node theme={null}
  import FirecrawlApp, { ScrapeResponse } from '@mendable/firecrawl-js';

  const app = new FirecrawlApp({apiKey: "fc-YOUR_API_KEY"});

  // 抓取一个网站：
  const scrapeResult = await app.scrapeUrl('airbnb.com', { formats: ['markdown', 'html'], location: {
      country: "BR",
      languages: ["pt-BR"]
  } }) as ScrapeResponse;

  if (!scrapeResult.success) {
    throw new Error(`抓取失败: ${scrapeResult.error}`)
  }

  console.log(scrapeResult)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.firecrawl.dev/v1/scrape \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -d '{
          "url": "airbnb.com",
          "formats": ["markdown"],
          "location": {
              "country": "BR",
              "languages": ["pt-BR"]
          }
      }'
  ```
</CodeGroup>

## 第一天 - 批量抓取

现在您可以使用我们的新批量端点同时抓取多个 URL。适用于不需要立即获得抓取结果的情况。

### 工作原理

它与`/crawl`端点的工作原理非常相似。它提交一个批量抓取作业并返回一个作业 ID，用于检查批量抓取的状态。
sdk 提供了同步和异步两种方法。同步方法将返回批量抓取作业的结果，而异步方法将返回一个作业 ID，您可以使用该 ID 来检查批量抓取的状态。

### 使用方法

<CodeGroup>
  ```python Python theme={null}
  from firecrawl import FirecrawlApp

  app = FirecrawlApp(api_key="fc-YOUR_API_KEY")

  # 抓取多个网站：
  batch_scrape_result = app.batch_scrape_urls(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']})
  print(batch_scrape_result)

  # 或者，您可以使用异步方法：
  batch_scrape_job = app.async_batch_scrape_urls(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']})
  print(batch_scrape_job)

  # (异步) 然后可以使用作业ID来检查批量抓取的状态：
  batch_scrape_status = app.check_batch_scrape_status(batch_scrape_job['id'])
  print(batch_scrape_status)
  ```

  ```js Node theme={null}
  import FirecrawlApp, { ScrapeResponse } from '@mendable/firecrawl-js';

  const app = new FirecrawlApp({apiKey: "fc-YOUR_API_KEY"});

  // 抓取多个网站（同步）:
  const batchScrapeResult = await app.batchScrapeUrls(['firecrawl.dev', 'mendable.ai'], { formats: ['markdown', 'html'] });

  if (!batchScrapeResult.success) {
    throw new Error(`抓取失败: ${batchScrapeResult.error}`);
  }
  // 输出批量抓取的所有结果:
  console.log(batchScrapeResult);

  // 或者，您可以使用异步方法:
  const batchScrapeJob = await app.asyncBulkScrapeUrls(['firecrawl.dev', 'mendable.ai'], { formats: ['markdown', 'html'] });
  console.log(batchScrapeJob);

  // (异步) 然后可以使用任务ID来检查批量抓取的状态:
  const batchScrapeStatus = await app.checkBatchScrapeStatus(batchScrapeJob.id);
  console.log(batchScrapeStatus);
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.firecrawl.dev/v1/batch/scrape \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer YOUR_API_KEY' \
      -d '{
        "urls": ["https://docs.firecrawl.dev", "https://docs.firecrawl.dev/sdks/overview"],
        "formats" : ["markdown", "html"]
      }'
  ```
</CodeGroup>

### 响应

如果您使用 SDK 中的同步方法，它将返回批量抓取作业的结果。否则，它将返回一个作业 ID，您可以使用该 ID 检查批量抓取的状态。

#### 同步

```json Completed theme={null}
{
  "status": "completed",
  "total": 36,
  "completed": 36,
  "creditsUsed": 36,
  "expiresAt": "2024-00-00T00:00:00.000Z",
  "next": "https://api.firecrawl.dev/v1/batch/scrape/123-456-789?skip=26",
  "data": [
    {
      "markdown": "[Firecrawl Docs home page![light logo](https://mintlify.s3-us-west-1.amazonaws.com/firecrawl/logo/light.svg)!...",
      "html": "<!DOCTYPE html><html lang=\"en\" class=\"js-focus-visible lg:[--scroll-mt:9.5rem]\" data-js-focus-visible=\"\">...",
      "metadata": {
        "title": "使用 Groq Llama 3 构建 '与网站聊天' | Firecrawl",
        "language": "en",
        "sourceURL": "https://docs.firecrawl.dev/learn/rag-llama3",
        "description": "了解如何使用 Firecrawl、Groq Llama 3 和 Langchain 来构建一个 '与您的网站聊天' 机器人。",
        "ogLocaleAlternate": [],
        "statusCode": 200
      }
    },
    ...
  ]
}
```

#### 异步

然后，您可以通过调用 `/batch/scrape/{id}` 端点，使用作业 ID 检查批量抓取的状态。此端点应在作业仍在运行或作业完成后立即使用**因为批量抓取作业在 24 小时后过期**。

```json theme={null}
{
  "success": true,
  "id": "123-456-789",
  "url": "https://api.firecrawl.dev/v1/batch/scrape/123-456-789"
}
```
