Loading...
Loading...
Compare original and translation side by side
/v2/scrape/v2/scrapeformatsonlyMainContentwaitForactionsformatsonlyMainContentwaitForactions/v2/crawl/v2/crawllimitmaxDepthallowedDomainsexcludePathslimitmaxDepthallowedDomainsexcludePaths/v2/map/v2/map/v2/extract/v2/extractschemasystemPromptschemasystemPromptfc-fc-undefinedundefined
```bash
```bash
---
---pip install firecrawl-py # v4.5.0+from firecrawl import FirecrawlApp
import os
app = FirecrawlApp(api_key=os.environ.get("FIRECRAWL_API_KEY"))
result = app.scrape_url("https://example.com", params={"formats": ["markdown"], "onlyMainContent": True})
print(result.get("markdown"))pip install firecrawl-py # v4.5.0+from firecrawl import FirecrawlApp
import os
app = FirecrawlApp(api_key=os.environ.get("FIRECRAWL_API_KEY"))
result = app.scrape_url("https://example.com", params={"formats": ["markdown"], "onlyMainContent": True})
print(result.get("markdown"))bun add @mendable/firecrawl-js # v4.4.1+import FirecrawlApp from '@mendable/firecrawl-js';
const app = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });
const result = await app.scrapeUrl('https://example.com', { formats: ['markdown'], onlyMainContent: true });
console.log(result.markdown);templates/bun add @mendable/firecrawl-js # v4.4.1+import FirecrawlApp from '@mendable/firecrawl-js';
const app = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY });
const result = await app.scrapeUrl('https://example.com', { formats: ['markdown'], onlyMainContent: true });
console.log(result.markdown);templates/| Use Case | Endpoint | Key Options |
|---|---|---|
| Documentation scraping | | |
| Product data extraction | | Zod schema + |
| News article scraping | | |
| URL discovery | | Find all pages before crawling |
references/common-patterns.md| 使用场景 | 端点 | 关键选项 |
|---|---|---|
| 文档抓取 | | |
| 产品数据提取 | | Zod schema + |
| 新闻文章抓取 | | |
| URL发现 | | 爬取前先找到所有页面 |
references/common-patterns.mdundefinedundefined
```typescript
// TypeScript
try {
const result = await app.scrapeUrl('https://example.com');
} catch (error) {
console.error('Error:', error.message);
}
```typescript
// TypeScript
try {
const result = await app.scrapeUrl('https://example.com');
} catch (error) {
console.error('错误:', error.message);
}| Best Practice | Why |
|---|---|
Use | Reduces credits, cleaner output |
Set reasonable | Avoid excessive costs |
Use | Plan crawling strategy |
| Cache results | Avoid re-scraping |
| Batch extract calls | More efficient for multiple URLs |
| 最佳实践 | 原因 |
|---|---|
使用 | 减少积分消耗,输出更简洁 |
设置合理的 | 避免过高成本 |
先使用 | 规划爬取策略 |
| 缓存结果 | 避免重复抓取 |
| 批量调用提取接口 | 处理多个URL更高效 |
const response = await fetch('https://api.firecrawl.dev/v2/scrape', {
method: 'POST',
headers: {
'Authorization': `Bearer ${env.FIRECRAWL_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ url, formats: ['markdown'], onlyMainContent: true })
});references/common-patterns.mdconst response = await fetch('https://api.firecrawl.dev/v2/scrape', {
method: 'POST',
headers: {
'Authorization': `Bearer ${env.FIRECRAWL_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ url, formats: ['markdown'], onlyMainContent: true })
});references/common-patterns.md| ✅ Use Firecrawl | ❌ Don't Use |
|---|---|
| Modern JS-rendered sites | Simple static HTML (use cheerio) |
| Clean markdown for LLMs | Existing Puppeteer setup works |
| RAG/chatbot content | Direct API available |
| Structured data extraction | Budget constraints |
| Bot protection bypass |
| ✅ 适合使用Firecrawl | ❌ 不适合使用 |
|---|---|
| 现代JS渲染站点 | 简单静态HTML(使用cheerio) |
| 为LLM生成干净的markdown | 现有Puppeteer配置可用 |
| RAG/聊天机器人内容 | 已有直接API可用 |
| 结构化数据提取 | 预算有限 |
| 绕过机器人防护 |
| Issue | Cause | Fix |
|---|---|---|
| "Invalid API Key" | Key not set | Check |
| "Rate limit exceeded" | Monthly credits used | Check dashboard, upgrade plan |
| "Timeout error" | Page slow to load | Add |
| "Content is empty" | JS loads late | Add |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| "Invalid API Key" | 密钥未设置 | 检查 |
| "Rate limit exceeded" | 月度积分已用完 | 查看控制台,升级套餐 |
| "Timeout error" | 页面加载缓慢 | 添加 |
| "Content is empty" | JS加载延迟 | 添加 |
| Feature | Usage |
|---|---|
| Browser actions | |
| Custom headers | |
| Webhooks | |
| Screenshots | |
references/endpoints.md| 功能 | 使用方式 |
|---|---|
| 浏览器操作 | |
| 自定义请求头 | |
| Webhooks | |
| 截图 | |
references/endpoints.md| Reference | Load When... |
|---|---|
| Need complete API endpoint documentation |
| Cloudflare Workers, caching, batch processing, error handling |
| 参考文档 | 加载时机 |
|---|---|
| 需要完整的API端点文档时 |
| 处理Cloudflare Workers、缓存、批量处理、错误处理时 |
| Package | Version |
|---|---|
| firecrawl-py | 4.5.0+ |
| @mendable/firecrawl-js | 4.4.1+ |
| API | v2 |
| 包 | 版本 |
|---|---|
| firecrawl-py | 4.5.0+ |
| @mendable/firecrawl-js | 4.4.1+ |
| API | v2 |