3 ways to ingest data from websites with Firecrawl#
You can also check this cookbook in colab here
In this blog, we’ll introduce Firecrawl, a versatile web scraping and crawling tool designed to extract data efficiently from websites, which has been integrated with CAMEL. Today we’ll walk through three key features—Scrape, Crawl, and Map—each tailored with a CAMEL agent use case.
Table of Content:#
Introduction
🔥 Firecrawl: To crawl
🔥 Firecrawl: To Scrape
🔥 Firecrawl: To Map
Conclusion
⭐ Star the Repo
If you find CAMEL useful or interesting, please consider giving it a star on our CAMEL GitHub Repo! Your stars help others find this project and motivate us to continue improving it.
Introduction#
Firecrawl developed by the Mendable.ai team, is a data ingestion tool that streamlines web data extraction using web scraping, API access, and automated browser interactions. It’s ideal for collecting structured and unstructured data from websites for analytics.
It effectively manages complex tasks such as handling reverse proxies, implementing caching strategies, adhering to rate limits, and accessing content blocked by JavaScript.
Features of Firecrawl:#
Crawl: Collects content from all URLs within a web page, converting it into an LLM-ready format for seamless analysis.
Scrape: Extracts content from a single URL, delivering it in formats ready for LLMs, including markdown, structured data (via LLM Extract), screenshots, and HTML.
Map: Inputs a website and retrieves all URLs associated with it at high speed, enabling a comprehensive and efficient site overview.
All the above features make it ideal for collecting structured and unstructured data from websites for agentic workflows. CAMEL-AI has integrated Firecrawl to enhance its web data extraction capabilities.
First, install the CAMEL package with all its dependencies and input the OPENAI API Key.
[ ]:
pip install "camel-ai[all]==0.2.11"
[ ]:
import os
from getpass import getpass
# Prompt for the API key securely
openai_api_key = getpass('Enter your API key: ')
os.environ["OPENAI_API_KEY"] = openai_api_key
Enter your API key: ··········
🔥 Firecrawl: To crawl#
Let’s get started with the exploration of the first feature of Firecrawl - Crawl: Extracts content from all subpages in an LLM-ready format (markdown, structured data, screenshot, HTML, links, metadata) for easy analysis.
Step 1: Set up your firecrawl API key
You just need to go to this link and sign in to get your API Key: https://www.firecrawl.dev/app/api-keys
[ ]:
import os
from getpass import getpass
# Prompt for the Firecrawl API key securely
firecrawl_api_key = getpass('Enter your API key: ')
os.environ["FIRECRAWL_API_KEY"] = firecrawl_api_key
Enter your API key: ··········
Step 2: Import necessary modules
[ ]:
from camel.loaders import Firecrawl
Step 3: Crawl the website
It will crawl the CAMEL-AI website and generate the LLM-friendly output as shown in markdown below.
[ ]:
# Initialize the Firecrawl instance
firecrawl = Firecrawl()
# Use the `crawl` method to retrieve content from the specified URL
firecrawl_response = firecrawl.crawl(
url="https://www.camel-ai.org/about" # Target URL to crawl for content
)
print(firecrawl_response["status"])
# Print the markdown content from the first page in the crawled data
print(firecrawl_response["data"][0]["markdown"])
completed
Camel-AI Team
# We are finding the scaling law of agent
🐫 CAMEL is an open-source library designed for the study of autonomous and communicative agents. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we implement and support various types of agents, tasks, prompts, models, and simulated environments.
**We are** always looking for more **contributors** and **collaborators**. Contact us to join forces。
[Slack](https://join.slack.com/t/camel-kwr1314/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA) [Discord](https://discord.gg/CNcNpquyDc)
#### All contributors
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830ee9ab51435525e8c57a_1.jpeg)[lightaime](https://github.com/lightaime)
Commits:
116
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830ef16f49819f7dfa140e_3.png)[Wendong-Fan](https://github.com/Wendong-Fan)
Commits:
75
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830ef7600c40531b5c74e2_4.png)[Obs01ete](https://github.com/Obs01ete)
Commits:
38
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f2b0d41ffb78faa6c58_6.png)[dandansamax](https://github.com/dandansamax)
Commits:
35
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/6683d081f7586e59387edbb6_5.jpeg)[zechengz](https://github.com/zechengz)
Commits:
26
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f30d401b408fa35facf_7.png)[hammoudhasan](https://github.com/hammoudhasan)
Commits:
18
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f36c12354b7846c3a51_8.jpeg)[yiyiyi0817](https://github.com/yiyiyi0817)
Commits:
9
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f3a7bce11b6dbe3e222_9.jpeg)[HalberdOfPineapple](https://github.com/HalberdOfPineapple)
Commits:
9
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f3fb0c6b06595b037e4_10.jpeg)[ocss884](https://github.com/ocss884)
Commits:
9
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f43f41f537d536c5f5f_11.png)[Benjamin-eecs](https://github.com/Benjamin-eecs)
Commits:
8
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f479dfcbf180e4fd018_12.jpeg)[Appointat](https://github.com/Appointat)
Commits:
7
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f4e9f8f288796edd2b2_13.png)[zhiyu-01](https://github.com/zhiyu-01)
Commits:
5
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f58a5e4a625d5793931_14.jpeg)[rsrbk](https://github.com/rsrbk)
Commits:
4
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f5d7bce11b6dbe3f728_15.png)[HaniItani](https://github.com/HaniItani)
Commits:
3
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f63bf86deec6b7f1a09_16.png)[jjyaoao](https://github.com/jjyaoao)
Commits:
3
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f69b1a115cbcfe49dc5_17.jpeg)[willshang76](https://github.com/willshang76)
Commits:
3
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f6f1ee3fc17a837f847_18.jpeg)[hychen-naza](https://github.com/hychen-naza)
Commits:
2
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f760db8fb00b4739fd2_19.png)[FUYICC](https://github.com/FUYICC)
Commits:
2
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f7b524b86a3ebe633c1_20.jpeg)[koch3092](https://github.com/koch3092)
Commits:
2
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f81853d6f6c8f09fe8d_21.png)[cat-searcher-bot](https://github.com/cat-searcher-bot)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f86ef774fafa799e956_22.jpeg)[Undertone0809](https://github.com/Undertone0809)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f8abe25cfeebf796c94_23.jpeg)[ArnoldIOI](https://github.com/ArnoldIOI)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830f9c699384adbc10e9f8_24.jpeg)[ZIYU-DEEP](https://github.com/ZIYU-DEEP)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830fa9ce07b2ac7dffeaef_25.jpeg)[duducheng](https://github.com/duducheng)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830fb440bef9732785a628_26.png)[forever-ly](https://github.com/forever-ly)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830ff2f41f537d536d020e_27.jpeg)[EddieFahrenheit](https://github.com/EddieFahrenheit)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830ff823bea7f626c0e3a7_28.png)[riverfor](https://github.com/riverfor)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66830ffd23bea7f626c0e7fe_29.jpeg)[raywhoelse](https://github.com/raywhoelse)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/6683100268f1349b3eb6c055_30.jpeg)[ZackYule](https://github.com/ZackYule)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/668310074683c2253ba26897_31.jpeg)[fengju0213](https://github.com/fengju0213)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/6683100b6b83da024d9eceff_32.jpeg)[Skevinci](https://github.com/Skevinci)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/6683100ea0d0bbb5aa97c1f1_33.jpeg)[eltociear](https://github.com/eltociear)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/66831013feedb63ddc545bf3_34.jpeg)[tczhangzhi](https://github.com/tczhangzhi)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/668310184a5c41506fd7f350_35.jpeg)[fbaldassarri](https://github.com/fbaldassarri)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/6683101c2dcf19fe9a1f95da_36.png)[zeromquan](https://github.com/zeromquan)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/6683101f524b86a3ebe6b127_37.png)[onemquan](https://github.com/onemquan)
Commits:
1
![](https://cdn.prod.website-files.com/6659a155491a54a40551bd7f/668310236c11244074a2aae8_38.jpeg)[zestor](https://github.com/zestor)
Commits:
1
## Our Advisors
[![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/66c6091430068e70376b2434_KAUST-CEMSE-EE-VCC-IVUL-Bernard-Ghanem-2045-edited-4k.jpg)\\
Bernard Ghanem\\
\\
King Abdullah University of Science and Technology\\
\\
- Rising star professor in the Middle East region \\
- He was Awarded the Shoman Arab Researcher Award for the topic of Machine Learning and Big Data\\
- Deputy Director of AI Initiative at Kaust and now leading a bigger initiative at Kaust on GenAI](https://cemse.kaust.edu.sa/people/person/bernard-ghanem) [![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/66c609ea3025b97ff20628a6_Philip_torr.jpg)\\
Philip Torr\\
\\
University of Oxford\\
\\
- 2019: Fellow of the Royal Academy of Engineering (FREng) in 2019\\
- 2021: Fellow of the Royal Society (FRS) for contributions to computer vision\\
- 2021: Turing AI world leading researcher fellow](https://eng.ox.ac.uk/people/philip-torr/)
Get started
## Build your multi-agent system today
Get started by joining our community
[Join Discord](http://discord.camel-ai.org/)
![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/6686afd48a4c823499baa2e7_Camel%20Logo%20Long.png)
Finding the scaling law of agents
![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/6659a155491a54a40551bd92_mail.svg)
RESEARCH
[CAMEL](https://github.com/camel-ai/camel) [Agent Trust](https://agent-trust.camel-ai.org/) [CRAB](https://github.com/camel-ai/crab?tab=readme-ov-file)
RESOURCES
[News](/news) [Blog](/blog) [Docs](https://docs.camel-ai.org/) [Integrations](/integration) [Team](/team)
Get UPdates
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
[![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/6675648577704e5e10bcdc87_Discord.svg)](http://discord.camel-ai.org/)[![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/66756482a95ea32bb2904c70_Github.svg)](https://github.com/camel-ai/camel)[![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/6736730d49b99ccd0c366086_Linkedin.svg)](https://www.linkedin.com/company/camel-ai-org/)[![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/673673125c8feebf7af520bd_X.svg)](https://x.com/CamelAIOrg)[![](https://cdn.prod.website-files.com/6659a154491a54a40551bc78/673672ff21614854f86a459c_youtube-color_svgrepo.com.svg)](https://www.youtube.com/@CamelAI)
Copyright © 2024 Eigent AI - All Rights Reserved.
Step 4: Interact with CAMEL agent
[ ]:
from camel.agents import ChatAgent
# Initialize a ChatAgent
agent = ChatAgent(
system_message="You're a helpful assistant", # Define the agent's role or purpose
)
# Use the ChatAgent to generate a response based on the Firecrawl crawl data
response = agent.step(f"Based on {firecrawl_response}, explain what CAMEL is.")
# Print the content of the first message in the response, which contains the assistant's answer
print(response.msgs[0].content)
CAMEL is an open-source library designed for the study of autonomous and communicative agents. The primary goal of CAMEL is to explore the scaling laws of these agents, which involves understanding their behaviors, capabilities, and potential risks when studied on a large scale. The library facilitates research by providing various types of agents, tasks, prompts, models, and simulated environments.
CAMEL encourages collaboration and contributions from the community, inviting researchers and developers to join their efforts. They have established communication channels through platforms like Slack and Discord for interested contributors to connect and collaborate.
The project is supported by a team of contributors and advisors, including notable figures in the field of artificial intelligence and machine learning. CAMEL aims to advance the understanding of multi-agent systems and their applications in various domains.
🔥 Firecrawl: To Scrape#
Scrape: This feature allows you to extract content from a single URL and convert it into various formats optimized for LLMs. The data is delivered in markdown, structured data (via LLM Extract), screenshots, or raw HTML, making it versatile for analysis and integration with other AI applications.
[ ]:
# Define the schema
class ExtractSchema(BaseModel):
company_mission: str
is_open_source: bool
# Perform the structured scrape
response = firecrawl.structured_scrape(
url='https://www.camel-ai.org/about', # URL to scrape data from
response_format=ExtractSchema
)
print(response)
{'company_mission': 'We are finding the scaling law of agent', 'is_open_source': True}
Let’s have a look how the assistant CAMEL agent can answer our questions with the response from Firecrawl.
[ ]:
# Use the ChatAgent to generate a response based on the Firecrawl crawl data
response = agent.step(f"Based on {response}, explain what the company mission of CAMEL is.")
# Print the content of the first message in the response, which contains the assistant's answer
print(response.msgs[0].content)
The company mission of CAMEL is to find the scaling law of agents. This involves researching and understanding how the performance and behavior of autonomous and communicative agents change as they are scaled up in size, complexity, or number. The scaling law refers to the relationship between the size of the agents (or the systems they operate within) and their capabilities, efficiency, or effectiveness.
By focusing on this mission, CAMEL aims to uncover valuable insights into how agents function in various environments and tasks, which can lead to improvements in the design and implementation of artificial intelligence systems. This research is crucial for developing more advanced and capable AI agents that can operate effectively in real-world applications.
Additionally, CAMEL's commitment to being open-source indicates that they prioritize collaboration and transparency, allowing researchers and developers to contribute to and benefit from their findings in the field of artificial intelligence.
🔥 Firecrawl: To Map#
Map: This feature takes a website as input and rapidly retrieves all associated URLs, providing a quick and comprehensive overview of the site’s structure. This high-speed mapping is ideal for efficient content discovery and organization.
[ ]:
# Call the `map_site` function from Firecrawl to retrieve all URLs from the specified website
map_result = firecrawl.map_site(
url="https://www.camel-ai.org" # Target URL to map
)
# Print the resulting map, which should contain all associated URLs from the website
print(map_result)
{'success': True, 'links': ['https://www.camel-ai.org', 'https://www.camel-ai.org/blog', 'https://www.camel-ai.org/checkout', 'https://www.camel-ai.org/news', 'https://www.camel-ai.org/order-confirmation', 'https://www.camel-ai.org/paypal-checkout', 'https://www.camel-ai.org/team', 'https://www.camel-ai.org/integration', 'https://www.camel-ai.org/search', 'https://www.camel-ai.org/about', 'https://www.camel-ai.org/post/crab', 'https://www.camel-ai.org/post/releasenotes-sprint4', 'https://www.camel-ai.org/post/releasenotes-sprint56', 'https://www.camel-ai.org/post/tool-usage', 'https://www.camel-ai.org/post/releasenotes-9', 'https://www.camel-ai.org/post/release-notes-10', 'https://www.camel-ai.org/post/realise-notes-9', 'https://www.camel-ai.org/post/realise-notes-8', 'https://www.camel-ai.org/post/getting-started-with-camel-ai', 'https://www.camel-ai.org/post/camel-release-notes-sprint-13', 'https://www.camel-ai.org/post/camel-release-notes-sprint-7', 'https://www.camel-ai.org/post/camel-release-notes-sprint-11', 'https://www.camel-ai.org/post/camel-release-notes-sprint-12', 'https://www.camel-ai.org/post/get-started-with-retrieval-augmented-generation', 'https://www.camel-ai.org/post/get-started-with-models---camel-101', 'https://www.camel-ai.org/post/week-4-of-may-camel-ai-release-notes', 'https://www.camel-ai.org/post/week-1-of-june-camel-ai-release-notes', 'https://www.camel-ai.org/post/3-ways-to-supercharge-camel-agents-with-web-data-using-firecrawl', 'https://www.camel-ai.org/post/mission-at-camel-ai-org-finding-the-scaling-laws-of-agents']}
[ ]:
# Use the ChatAgent to generate a response based on the Firecrawl crawl data
response = agent.step(f"Based on {map_result}, which one is the main website for CAMEL-AI.")
# Print the content of the first message in the response, which contains the assistant's answer
print(response.msgs[0].content)
The main website for CAMEL-AI is [https://www.camel-ai.org](https://www.camel-ai.org).
Conclusion#
In conclusion, using Firecrawl within the CAMEL framework streamlines the process of web data extraction and enhances your agents capabilities. With Firecrawl’s powerful features like Scrape, Crawl, and Map, you can efficiently gather content in formats ready for LLMs to use, directly feeding into CAMEL-AI’s multi-agent workflows. This setup not only simplifies data collection but also enables more intelligent and insightful agents.
⭐ Star the Repo
If you find CAMEL useful or interesting, please consider giving it a star on GitHub! Your stars help others find this project and motivate us to continue improving it.