MCPcopy
hub / github.com/firecrawl/firecrawl / main

Function main

apps/python-sdk/example.py:13–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11load_dotenv()
12
13def main():
14 api_key = os.getenv("FIRECRAWL_API_KEY")
15 if not api_key:
16 raise ValueError("FIRECRAWL_API_KEY is not set")
17
18 api_url = os.getenv("FIRECRAWL_API_URL")
19 if not api_url:
20 raise ValueError("FIRECRAWL_API_URL is not set")
21
22 firecrawl = Firecrawl(api_key=api_key, api_url=api_url)
23
24 # Scrape
25 doc = firecrawl.scrape("https://docs.firecrawl.dev", formats=["markdown"])
26 print("scrape:", doc.markdown)
27 # doc.metadata_dict is a dict, doc.metadata_typed is a DocumentMetadata object
28 print(doc.metadata_dict.get("source_url"))
29 print('metadata_dict.get("title"):', doc.metadata_dict.get("title"))
30 print("metadata_typed.title:", doc.metadata_typed.title)
31 print("metadata.title", doc.metadata.title if doc.metadata else None)
32
33
34 # Crawl (waits until terminal state)
35 crawl_job = firecrawl.crawl("https://docs.firecrawl.dev", limit=3, poll_interval=1, timeout=120)
36 print("crawl:", crawl_job.status, crawl_job.completed, "/", crawl_job.total)
37
38 # Batch scrape
39 batch = firecrawl.batch_scrape([
40 "https://docs.firecrawl.dev",
41 "https://firecrawl.dev",
42 ], formats=["markdown"], poll_interval=1, wait_timeout=120)
43 print("batch:", batch.status, batch.completed, "/", batch.total)
44
45 # Search
46 search_response = firecrawl.search(query="What is the capital of France?", limit=5)
47 print("search web results:", len(getattr(search_response, "web", []) or []))
48
49 # Map
50 map_response = firecrawl.map("https://firecrawl.dev")
51 print("map links:", len(getattr(map_response, "links", []) or []))
52
53if __name__ == "__main__":
54 main()

Callers 1

example.pyFile · 0.70

Calls 7

FirecrawlClass · 0.90
scrapeMethod · 0.45
getMethod · 0.45
crawlMethod · 0.45
batch_scrapeMethod · 0.45
searchMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…