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.
欢迎来到 Firecrawl
Firecrawl 是一个 API 服务,它接受一个 URL,进行爬取,并将其转换为干净的 Markdown。我们会爬取所有可访问的子页面,并为您提供每个页面的干净 Markdown。不需要站点地图。
如何使用?
我们提供了易于使用的 API,通过托管版本提供。您可以在 这里 找到游乐场和文档。如果您愿意,也可以自行托管后端。
请查看以下资源以开始使用:
API : 文档
SDKs : Python , Node , Go , Rust
LLM 框架 : Langchain (python) , Langchain (js) , Llama Index , Crew.ai , Composio , PraisonAI , Superinterface , Vectorize
低代码框架 : Dify , Langflow , Flowise AI , Cargo , Pipedream
其他 : Zapier , Pabbly Connect
需要 SDK 或集成吗?通过打开一个 issue 告诉我们。
自托管 : 要进行自托管,请参考指南 这里 。
API 密钥
要使用 API,您需要在 Firecrawl 上注册并获取一个 API 密钥。
用于爬取一个 URL 及其所有可访问的子页面。这会提交一个爬取任务并返回一个任务 ID,用于检查爬取状态。
Python
JavaScript
Go
Rust
cURL
from firecrawl import FirecrawlApp
app = FirecrawlApp( api_key = "YOUR_API_KEY" )
crawl_result = app.crawl_url( 'docs.firecrawl.dev' , { 'crawlerOptions' : { 'excludes' : [ 'blog/*' ]}})
# Get the markdown
for result in crawl_result:
print (result[ 'markdown' ])
如果你不使用 SDK 或更喜欢使用 Webhook 或其他轮询方法,可以将 wait_until_done 设置为 false。
这会返回一个 jobId。
对于 cURL,/crawl 始终会返回一个 jobId,你可以用它来检查抓取的状态。
{ "jobId" : "1234-5678-9101" }
检查抓取作业
用于检查抓取作业的状态并获取其结果。
Python
JavaScript
Go
Rust
cURL
status = app.check_crawl_status(job_id)
{
"status" : "completed" ,
"current" : 22 ,
"total" : 22 ,
"data" : [
{
"content" : "Raw Content " ,
"markdown" : "# Markdown Content" ,
"provider" : "web-scraper" ,
"metadata" : {
"title" : "Firecrawl | Scrape the web reliably for your LLMs" ,
"description" : "AI for CX and Sales" ,
"language" : null ,
"sourceURL" : "https://docs.firecrawl.dev/"
}
}
]
}
要抓取单个 URL,请使用 scrape_url 方法。它接受 URL 作为参数,并返回抓取的数据作为字典。
Python
JavaScript
Go
Rust
cURL
from firecrawl import FirecrawlApp
app = FirecrawlApp( api_key = "YOUR_API_KEY" )
content = app.scrape_url( "https://docs.firecrawl.dev" )
{
"success" : true ,
"data" : {
"markdown" : "<string>" ,
"content" : "<string>" ,
"html" : "<string>" ,
"rawHtml" : "<string>" ,
"metadata" : {
"title" : "<string>" ,
"description" : "<string>" ,
"language" : "<string>" ,
"sourceURL" : "<string>" ,
"<any other metadata> " : "<string>" ,
"pageStatusCode" : 123 ,
"pageError" : "<string>"
},
"llm_extraction" : {},
"warning" : "<string>"
}
}
提取数据
通过 LLM 提取功能,你可以轻松地从任何 URL 中提取结构化数据。我们支持 pydantic 模式,使其更易于使用。以下是如何使用它的示例:
Python
JavaScript
Go
Rust
cURL
class ArticleSchema ( BaseModel ):
title: str
points: int
by: str
commentsURL: str
class TopArticlesSchema ( BaseModel ):
top: List[ArticleSchema] = Field( ... , max_items = 5 , description = "Top 5 stories" )
data = app.scrape_url( 'https://news.ycombinator.com' , {
'extractorOptions' : {
'extractionSchema' : TopArticlesSchema.model_json_schema(),
'mode' : 'llm-extraction'
},
'pageOptions' :{
'onlyMainContent' : True
}
})
print (data[ "llm_extraction" ])
我们欢迎任何形式的贡献!在提交拉取请求之前,请阅读我们的贡献指南 。