メインコンテンツへスキップ

前提条件

SDKのインストール

pip install firecrawl-py

Webを検索

from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")
results = app.search("firecrawl web scraping", limit=5)

for result in results.web:
    print(result.title, result.url)

ページをスクレイピングする

result = app.scrape("https://example.com")
print(result.markdown)
{
  "markdown": "# Example Domain\n\nThis domain is for use in illustrative examples...",
  "metadata": {
    "title": "Example Domain",
    "sourceURL": "https://example.com"
  }
}

Interact でページを操作する

Interact を使用して実行中のブラウザセッションを操作し、ボタンのクリック、フォームへの入力、動的コンテンツの抽出を行えます。
result = app.scrape("https://www.amazon.com", formats=["markdown"])
scrape_id = result.metadata.scrape_id

app.interact(scrape_id, prompt="Search for iPhone 16 Pro Max")
response = app.interact(scrape_id, prompt="Click on the first result and tell me the price")
print(response.output)

app.stop_interaction(scrape_id)

環境変数

api_key を直接渡す代わりに、FIRECRAWL_API_KEY 環境変数を設定してください:
export FIRECRAWL_API_KEY=fc-YOUR-API-KEY
app = Firecrawl()

次のステップ

スクレイピングのドキュメント

フォーマット、アクション、プロキシなど、スクレイピングのオプションをすべて掲載

検索ドキュメント

Webを検索してページ全体のコンテンツを取得

Interact ドキュメント

クリック、フォーム入力、動的コンテンツの抽出

Python SDK リファレンス

クロール、map、async などを網羅した SDK リファレンス