Installation#
pip install 'firecrawl-py>=4.3.3' llama-index llama-index-readers-webUsage#
FireCrawlWebReader supports scrape, crawl, map, search, and extract modes.
Using Firecrawl to Gather an Entire Website#
from llama_index.readers.web import FireCrawlWebReaderfrom llama_index.core import SummaryIndeximport os# Initialize FireCrawlWebReader to crawl a websitefirecrawl_reader = FireCrawlWebReader( api_key="<your_api_key>", # Replace with your actual API key from https://www.firecrawl.dev/ mode="crawl", # "scrape", "crawl", "map", "search", or "extract" params={"additional": "parameters"} # Optional additional parameters)# Set the environment variable for the virtual keyos.environ["OPENAI_API_KEY"] = "<OPENAI_API_KEY>"# Load documents from a single page URLdocuments = firecrawl_reader.load_data(url="http://paulgraham.com/")index = SummaryIndex.from_documents(documents)# Set Logging to DEBUG for more detailed outputsquery_engine = index.as_query_engine()response = query_engine.query("What did the author do growing up?")display(Markdown(f"<b>{response}</b>"))Using Firecrawl to Gather a Single Page#
from llama_index.readers.web import FireCrawlWebReader# Initialize the FireCrawlWebReader with your API key and desired modefirecrawl_reader = FireCrawlWebReader( api_key="<your_api_key>", # Replace with your actual API key from https://www.firecrawl.dev/ mode="scrape", # "scrape", "crawl", "map", "search", or "extract" params={"additional": "parameters"} # Optional additional parameters)# Load documents from a specified URLdocuments = firecrawl_reader.load_data(url="http://paulgraham.com/worked.html")index = SummaryIndex.from_documents(documents)# Set Logging to DEBUG for more detailed outputsquery_engine = index.as_query_engine()response = query_engine.query("What did the author do growing up?")display(Markdown(f"<b>{response}</b>"))
