Documentation Index Fetch the complete documentation index at: https://firecrawl-mog-search-exclude-include-domains.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Elixir 1.14+ 和 OTP 25+
一个 Firecrawl API 密钥——免费获取
将 firecrawl 添加到 mix.exs 中:
defp deps do
[
{ :firecrawl , "~> 1.0" }
]
end
在 config/config.exs 中配置您的 API 密钥:
config :firecrawl , api_key: System . get_env ( "FIRECRAWL_API_KEY" )
{ :ok , result} = Firecrawl . search_and_scrape ( query: "firecrawl web scraping" , limit: 5 )
for entry <- result.body[ "data" ][ "web" ] do
IO . puts ( " #{ entry[ "title" ] } - #{ entry[ "url" ] } " )
end
{ :ok , result} = Firecrawl . scrape_and_extract_from_url ( url: "https://example.com" )
IO . puts (result.body[ "data" ][ "markdown" ])
{
"success" : true ,
"data" : {
"markdown" : "# Example Domain \n\n This domain is for use in illustrative examples..." ,
"metadata" : {
"title" : "Example Domain" ,
"sourceURL" : "https://example.com"
}
}
}
先抓取页面,再通过浏览器会话 API 继续与其交互。
{ :ok , scrape} = Firecrawl . scrape_and_extract_from_url (
url: "https://www.amazon.com" ,
formats: [ "markdown" ]
)
scrape_id = get_in (scrape.body, [ "data" , "metadata" , "scrapeId" ])
# 使用 REST API 进行交互(基于 prompt)
headers = [
{ "Authorization" , "Bearer #{ Application . get_env ( :firecrawl , :api_key ) } " },
{ "Content-Type" , "application/json" }
]
{ :ok , _ } = Req . post (
"https://api.firecrawl.dev/v2/scrape/ #{ scrape_id } /interact" ,
json: %{ prompt: "Search for iPhone 16 Pro Max" },
headers: headers
)
{ :ok , response} = Req . post (
"https://api.firecrawl.dev/v2/scrape/ #{ scrape_id } /interact" ,
json: %{ prompt: "Click on the first result and tell me the price" },
headers: headers
)
IO . inspect (response.body)
# 停止会话
Req . delete (
"https://api.firecrawl.dev/v2/scrape/ #{ scrape_id } /interact" ,
headers: headers
)
请设置 FIRECRAWL_API_KEY,不要将其硬编码:
export FIRECRAWL_API_KEY = fc-YOUR-API-KEY
抓取 文档 涵盖所有 scrape 选项,包括 formats、actions 和代理
Elixir SDK 参考 完整的 SDK 参考,涵盖爬取、map、batch scrape 等