firecrawl/README.md

198 lines
5.7 KiB
Markdown
Raw Normal View History

2024-04-15 21:01:47 +00:00
# 🔥 Firecrawl
2024-04-15 21:53:47 +00:00
Crawl and convert any website into LLM-ready markdown. Build by [Mendable.ai](https://mendable.ai?ref=gfirecrawl)
2024-04-15 21:01:47 +00:00
2024-04-24 17:16:23 +00:00
_This repository is currently in its early stages of development. We are in the process of merging custom modules into this mono repository. The primary objective is to enhance the accuracy of LLM responses by utilizing clean data. It is not ready for full self-host yet - we're working on it_
2024-04-15 21:01:47 +00:00
## What is Firecrawl?
[Firecrawl](https://firecrawl.dev?ref=github) is an API service that takes a URL, crawls it, and converts it into clean markdown. We crawl all accessible subpages and give you clean markdown for each. No sitemap required.
_Pst. hey, you, join our stargazers :)_
<img src="https://github.com/mendableai/firecrawl/assets/44934913/53c4483a-0f0e-40c6-bd84-153a07f94d29" width="200">
2024-04-15 21:01:47 +00:00
## How to use it?
2024-04-24 17:16:23 +00:00
We provide an easy to use API with our hosted version. You can find the playground and documentation [here](https://firecrawl.dev/playground). You can also self host the backend if you'd like.
2024-04-15 21:01:47 +00:00
2024-04-17 04:19:16 +00:00
- [x] [API](https://firecrawl.dev/playground)
2024-04-15 21:45:08 +00:00
- [x] [Python SDK](https://github.com/mendableai/firecrawl/tree/main/apps/python-sdk)
2024-04-24 17:16:23 +00:00
- [x] [Node SDK](https://github.com/mendableai/firecrawl/tree/main/apps/js-sdk)
2024-04-15 21:45:08 +00:00
- [x] [Langchain Integration 🦜🔗](https://python.langchain.com/docs/integrations/document_loaders/firecrawl/)
2024-04-18 04:50:41 +00:00
- [x] [Llama Index Integration 🦙](https://docs.llamaindex.ai/en/latest/examples/data_connectors/WebPageDemo/#using-firecrawl-reader)
2024-04-24 23:13:29 +00:00
- [X] [Langchain JS Integration 🦜🔗](https://js.langchain.com/docs/integrations/document_loaders/web_loaders/firecrawl)
- [ ] Want an SDK or Integration? Let us know by opening an issue.
2024-04-15 21:45:33 +00:00
2024-04-21 18:41:34 +00:00
To run locally, refer to guide [here](https://github.com/mendableai/firecrawl/blob/main/CONTRIBUTING.md).
2024-04-15 21:01:47 +00:00
### API Key
2024-04-17 04:19:16 +00:00
To use the API, you need to sign up on [Firecrawl](https://firecrawl.dev) and get an API key.
2024-04-24 17:16:23 +00:00
2024-04-15 21:01:47 +00:00
### Crawling
Used to crawl a URL and all accessible subpages. This submits a crawl job and returns a job ID to check the status of the crawl.
```bash
curl -X POST https://api.firecrawl.dev/v0/crawl \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"url": "https://mendable.ai"
}'
```
Returns a jobId
```json
{ "jobId": "1234-5678-9101" }
```
### Check Crawl Job
Used to check the status of a crawl job and get its result.
```bash
curl -X GET https://api.firecrawl.dev/v0/crawl/status/1234-5678-9101 \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY'
```
```json
{
2024-04-24 17:16:23 +00:00
"status": "completed",
"current": 22,
"total": 22,
"data": [
{
"content": "Raw Content ",
"markdown": "# Markdown Content",
"provider": "web-scraper",
"metadata": {
"title": "Mendable | AI for CX and Sales",
"description": "AI for CX and Sales",
"language": null,
"sourceURL": "https://www.mendable.ai/"
}
}
]
}
```
### Scraping
Used to scrape a URL and get its content.
```bash
curl -X POST https://api.firecrawl.dev/v0/scrape \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"url": "https://mendable.ai"
}'
```
Response:
```json
{
"success": true,
"data": {
"content": "Raw Content ",
"markdown": "# Markdown Content",
"provider": "web-scraper",
"metadata": {
"title": "Mendable | AI for CX and Sales",
"description": "AI for CX and Sales",
"language": null,
"sourceURL": "https://www.mendable.ai/"
}
}
}
```
2024-04-24 17:40:07 +00:00
### Search (Beta)
2024-04-24 17:16:23 +00:00
Used to search the web, get the most relevant results, scrap each page and return the markdown.
```bash
curl -X POST https://api.firecrawl.dev/v0/search \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
"query": "firecrawl",
"pageOptions": {
"fetchPageContent": true // false for a fast serp api
}
}'
```
```json
{
"success": true,
"data": [
{
"url": "https://mendable.ai",
"markdown": "# Markdown Content",
"provider": "web-scraper",
"metadata": {
"title": "Mendable | AI for CX and Sales",
"description": "AI for CX and Sales",
"language": null,
"sourceURL": "https://www.mendable.ai/"
}
}
]
2024-04-15 21:01:47 +00:00
}
```
2024-04-26 20:37:00 +00:00
Coming soon to the Langchain and LLama Index integrations.
2024-04-24 18:46:25 +00:00
2024-04-15 21:01:47 +00:00
## Using Python SDK
### Installing Python SDK
```bash
pip install firecrawl-py
```
### Crawl a website
```python
from firecrawl import FirecrawlApp
app = FirecrawlApp(api_key="YOUR_API_KEY")
crawl_result = app.crawl_url('mendable.ai', {'crawlerOptions': {'excludes': ['blog/*']}})
# Get the markdown
for result in crawl_result:
print(result['markdown'])
```
### Scraping a URL
To scrape a single URL, use the `scrape_url` method. It takes the URL as a parameter and returns the scraped data as a dictionary.
```python
url = 'https://example.com'
scraped_data = app.scrape_url(url)
```
2024-04-25 20:29:37 +00:00
### Search for a query
Performs a web search, retrieve the top results, extract data from each page, and returns their markdown.
```python
query = 'what is mendable?'
search_result = app.search(query)
```
2024-04-15 21:01:47 +00:00
## Contributing
We love contributions! Please read our [contributing guide](CONTRIBUTING.md) before submitting a pull request.
2024-04-28 18:41:42 +00:00
2024-04-28 20:06:46 +00:00
*It is the sole responsibility of the end users to respect websites' policies when scraping, searching and crawling with Firecrawl. Users are advised to adhere to the applicable privacy policies and terms of use of the websites prior to initiating any scraping activities. By default, Firecrawl respects the directives specified in the websites' robots.txt files when crawling. By utilizing Firecrawl, you expressly agree to comply with these conditions.*