firecrawl 1.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of firecrawl might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Sideguide Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,291 @@
1
+ Metadata-Version: 2.1
2
+ Name: firecrawl
3
+ Version: 1.6.0
4
+ Summary: Python SDK for Firecrawl API
5
+ Home-page: https://github.com/mendableai/firecrawl
6
+ Author: Mendable.ai
7
+ Author-email: "Mendable.ai" <nick@mendable.ai>
8
+ Maintainer-email: "Mendable.ai" <nick@mendable.ai>
9
+ License: GNU Affero General Public License v3 (AGPLv3)
10
+ Project-URL: Documentation, https://docs.firecrawl.dev
11
+ Project-URL: Source, https://github.com/mendableai/firecrawl
12
+ Project-URL: Tracker, https://github.com/mendableai/firecrawl/issues
13
+ Keywords: SDK,API,firecrawl
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Environment :: Web Environment
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
18
+ Classifier: Natural Language :: English
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Topic :: Internet
26
+ Classifier: Topic :: Internet :: WWW/HTTP
27
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
28
+ Classifier: Topic :: Software Development
29
+ Classifier: Topic :: Software Development :: Libraries
30
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
31
+ Classifier: Topic :: Text Processing
32
+ Classifier: Topic :: Text Processing :: Indexing
33
+ Requires-Python: >=3.8
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: requests
37
+ Requires-Dist: python-dotenv
38
+ Requires-Dist: websockets
39
+ Requires-Dist: nest-asyncio
40
+
41
+ # Firecrawl Python SDK
42
+
43
+ The Firecrawl Python SDK is a library that allows you to easily scrape and crawl websites, and output the data in a format ready for use with language models (LLMs). It provides a simple and intuitive interface for interacting with the Firecrawl API.
44
+
45
+ ## Installation
46
+
47
+ To install the Firecrawl Python SDK, you can use pip:
48
+
49
+ ```bash
50
+ pip install firecrawl-py
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ 1. Get an API key from [firecrawl.dev](https://firecrawl.dev)
56
+ 2. Set the API key as an environment variable named `FIRECRAWL_API_KEY` or pass it as a parameter to the `FirecrawlApp` class.
57
+
58
+ Here's an example of how to use the SDK:
59
+
60
+ ```python
61
+ from firecrawl.firecrawl import FirecrawlApp
62
+
63
+ app = FirecrawlApp(api_key="fc-YOUR_API_KEY")
64
+
65
+ # Scrape a website:
66
+ scrape_status = app.scrape_url(
67
+ 'https://firecrawl.dev',
68
+ params={'formats': ['markdown', 'html']}
69
+ )
70
+ print(scrape_status)
71
+
72
+ # Crawl a website:
73
+ crawl_status = app.crawl_url(
74
+ 'https://firecrawl.dev',
75
+ params={
76
+ 'limit': 100,
77
+ 'scrapeOptions': {'formats': ['markdown', 'html']}
78
+ },
79
+ poll_interval=30
80
+ )
81
+ print(crawl_status)
82
+ ```
83
+
84
+ ### Scraping a URL
85
+
86
+ 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.
87
+
88
+ ```python
89
+ url = 'https://example.com'
90
+ scraped_data = app.scrape_url(url)
91
+ ```
92
+
93
+ ### Extracting structured data from a URL
94
+
95
+ With LLM extraction, you can easily extract structured data from any URL. We support pydantic schemas to make it easier for you too. Here is how you to use it:
96
+
97
+ ```python
98
+ class ArticleSchema(BaseModel):
99
+ title: str
100
+ points: int
101
+ by: str
102
+ commentsURL: str
103
+
104
+ class TopArticlesSchema(BaseModel):
105
+ top: List[ArticleSchema] = Field(..., max_items=5, description="Top 5 stories")
106
+
107
+ data = app.scrape_url('https://news.ycombinator.com', {
108
+ 'extractorOptions': {
109
+ 'extractionSchema': TopArticlesSchema.model_json_schema(),
110
+ 'mode': 'llm-extraction'
111
+ },
112
+ 'pageOptions':{
113
+ 'onlyMainContent': True
114
+ }
115
+ })
116
+ print(data["llm_extraction"])
117
+ ```
118
+
119
+ ### Crawling a Website
120
+
121
+ To crawl a website, use the `crawl_url` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format.
122
+
123
+ ```python
124
+ idempotency_key = str(uuid.uuid4()) # optional idempotency key
125
+ crawl_result = app.crawl_url('firecrawl.dev', {'excludePaths': ['blog/*']}, 2, idempotency_key)
126
+ print(crawl_result)
127
+ ```
128
+
129
+ ### Asynchronous Crawl a Website
130
+
131
+ To crawl a website asynchronously, use the `async_crawl_url` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format.
132
+
133
+ ```python
134
+ crawl_result = app.async_crawl_url('firecrawl.dev', {'excludePaths': ['blog/*']}, "")
135
+ print(crawl_result)
136
+ ```
137
+
138
+ ### Checking Crawl Status
139
+
140
+ To check the status of a crawl job, use the `check_crawl_status` method. It takes the job ID as a parameter and returns the current status of the crawl job.
141
+
142
+ ```python
143
+ id = crawl_result['id']
144
+ status = app.check_crawl_status(id)
145
+ ```
146
+
147
+ ### Map a Website
148
+
149
+ Use `map_url` to generate a list of URLs from a website. The `params` argument let you customize the mapping process, including options to exclude subdomains or to utilize the sitemap.
150
+
151
+ ```python
152
+ # Map a website:
153
+ map_result = app.map_url('https://example.com')
154
+ print(map_result)
155
+ ```
156
+
157
+ ### Crawl a website with WebSockets
158
+
159
+ To crawl a website with WebSockets, use the `crawl_url_and_watch` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format.
160
+
161
+ ```python
162
+ # inside an async function...
163
+ nest_asyncio.apply()
164
+
165
+ # Define event handlers
166
+ def on_document(detail):
167
+ print("DOC", detail)
168
+
169
+ def on_error(detail):
170
+ print("ERR", detail['error'])
171
+
172
+ def on_done(detail):
173
+ print("DONE", detail['status'])
174
+
175
+ # Function to start the crawl and watch process
176
+ async def start_crawl_and_watch():
177
+ # Initiate the crawl job and get the watcher
178
+ watcher = app.crawl_url_and_watch('firecrawl.dev', { 'excludePaths': ['blog/*'], 'limit': 5 })
179
+
180
+ # Add event listeners
181
+ watcher.add_event_listener("document", on_document)
182
+ watcher.add_event_listener("error", on_error)
183
+ watcher.add_event_listener("done", on_done)
184
+
185
+ # Start the watcher
186
+ await watcher.connect()
187
+
188
+ # Run the event loop
189
+ await start_crawl_and_watch()
190
+ ```
191
+
192
+ ### Scraping multiple URLs in batch
193
+
194
+ To batch scrape multiple URLs, use the `batch_scrape_urls` method. It takes the URLs and optional parameters as arguments. The `params` argument allows you to specify additional options for the scraper such as the output formats.
195
+
196
+ ```python
197
+ idempotency_key = str(uuid.uuid4()) # optional idempotency key
198
+ batch_scrape_result = app.batch_scrape_urls(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']}, 2, idempotency_key)
199
+ print(batch_scrape_result)
200
+ ```
201
+
202
+ ### Asynchronous batch scrape
203
+
204
+ To run a batch scrape asynchronously, use the `async_batch_scrape_urls` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the scraper, such as the output formats.
205
+
206
+ ```python
207
+ batch_scrape_result = app.async_batch_scrape_urls(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']})
208
+ print(batch_scrape_result)
209
+ ```
210
+
211
+ ### Checking batch scrape status
212
+
213
+ To check the status of an asynchronous batch scrape job, use the `check_batch_scrape_status` method. It takes the job ID as a parameter and returns the current status of the batch scrape job.
214
+
215
+ ```python
216
+ id = batch_scrape_result['id']
217
+ status = app.check_batch_scrape_status(id)
218
+ ```
219
+
220
+ ### Batch scrape with WebSockets
221
+
222
+ To use batch scrape with WebSockets, use the `batch_scrape_urls_and_watch` method. It takes the starting URL and optional parameters as arguments. The `params` argument allows you to specify additional options for the scraper, such as the output formats.
223
+
224
+ ```python
225
+ # inside an async function...
226
+ nest_asyncio.apply()
227
+
228
+ # Define event handlers
229
+ def on_document(detail):
230
+ print("DOC", detail)
231
+
232
+ def on_error(detail):
233
+ print("ERR", detail['error'])
234
+
235
+ def on_done(detail):
236
+ print("DONE", detail['status'])
237
+
238
+ # Function to start the crawl and watch process
239
+ async def start_crawl_and_watch():
240
+ # Initiate the crawl job and get the watcher
241
+ watcher = app.batch_scrape_urls_and_watch(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']})
242
+
243
+ # Add event listeners
244
+ watcher.add_event_listener("document", on_document)
245
+ watcher.add_event_listener("error", on_error)
246
+ watcher.add_event_listener("done", on_done)
247
+
248
+ # Start the watcher
249
+ await watcher.connect()
250
+
251
+ # Run the event loop
252
+ await start_crawl_and_watch()
253
+ ```
254
+
255
+ ## Error Handling
256
+
257
+ The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message.
258
+
259
+ ## Running the Tests with Pytest
260
+
261
+ To ensure the functionality of the Firecrawl Python SDK, we have included end-to-end tests using `pytest`. These tests cover various aspects of the SDK, including URL scraping, web searching, and website crawling.
262
+
263
+ ### Running the Tests
264
+
265
+ To run the tests, execute the following commands:
266
+
267
+ Install pytest:
268
+
269
+ ```bash
270
+ pip install pytest
271
+ ```
272
+
273
+ Run:
274
+
275
+ ```bash
276
+ pytest firecrawl/__tests__/e2e_withAuth/test.py
277
+ ```
278
+
279
+ ## Contributing
280
+
281
+ Contributions to the Firecrawl Python SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
282
+
283
+ ## License
284
+
285
+ The Firecrawl Python SDK is licensed under the MIT License. This means you are free to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the SDK, subject to the following conditions:
286
+
287
+ - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
288
+
289
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
290
+
291
+ Please note that while this SDK is MIT licensed, it is part of a larger project which may be under different licensing terms. Always refer to the license information in the root directory of the main project for overall licensing details.
@@ -0,0 +1,11 @@
1
+ firecrawl/__init__.py,sha256=9mQfSNKz0VYJilNxhiaYwxWw2gMvUA1Ql2SUnGXCivY,2543
2
+ firecrawl/firecrawl.py,sha256=RcOaoGUs-JWvz2Xy8W5eEizoVZnE3RCbb8P75RAc1JQ,30207
3
+ firecrawl/__tests__/e2e_withAuth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ firecrawl/__tests__/e2e_withAuth/test.py,sha256=L-umFR3WyrJso1EwqkxjbTMr5AEI4t5zDfhQcCzitOI,7911
5
+ firecrawl/__tests__/v1/e2e_withAuth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ firecrawl/__tests__/v1/e2e_withAuth/test.py,sha256=KQMmGAtJAIafja6EGtJ-W9162w2Hm6PNjqKl3_RQXLA,16456
7
+ firecrawl-1.6.0.dist-info/LICENSE,sha256=nPCunEDwjRGHlmjvsiDUyIWbkqqyj3Ej84ntnh0g0zA,1084
8
+ firecrawl-1.6.0.dist-info/METADATA,sha256=AvmxvRgdpvL-pTdz43kUd1DhgPX4evG1tV6yUJhUda8,10596
9
+ firecrawl-1.6.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
10
+ firecrawl-1.6.0.dist-info/top_level.txt,sha256=jTvz79zWhiyAezfmmHe4FQ-hR60C59UU5FrjMjijLu8,10
11
+ firecrawl-1.6.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.38.4)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ firecrawl