firecrawl 2.4.0__py3-none-any.whl → 2.4.2__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.

firecrawl/__init__.py CHANGED
@@ -13,7 +13,7 @@ import os
13
13
 
14
14
  from .firecrawl import FirecrawlApp, JsonConfig, ScrapeOptions # noqa
15
15
 
16
- __version__ = "2.4.0"
16
+ __version__ = "2.4.2"
17
17
 
18
18
  # Define the logger for the Firecrawl project
19
19
  logger: logging.Logger = logging.getLogger("firecrawl")
firecrawl/firecrawl.py CHANGED
@@ -210,6 +210,7 @@ class ScrapeParams(ScrapeOptions):
210
210
  jsonOptions: Optional[JsonConfig] = None
211
211
  actions: Optional[List[Union[WaitAction, ScreenshotAction, ClickAction, WriteAction, PressAction, ScrollAction, ScrapeAction, ExecuteJavascriptAction]]] = None
212
212
  agent: Optional[AgentOptions] = None
213
+ webhook: Optional[WebhookConfig] = None
213
214
 
214
215
  class ScrapeResponse(FirecrawlDocument[T], Generic[T]):
215
216
  """Response from scraping operations."""
@@ -2432,15 +2433,15 @@ class FirecrawlApp:
2432
2433
  "batch_scrape_urls": {"formats", "headers", "include_tags", "exclude_tags", "only_main_content",
2433
2434
  "wait_for", "timeout", "location", "mobile", "skip_tls_verification",
2434
2435
  "remove_base64_images", "block_ads", "proxy", "extract", "json_options",
2435
- "actions", "agent"},
2436
+ "actions", "agent", "webhook"},
2436
2437
  "async_batch_scrape_urls": {"formats", "headers", "include_tags", "exclude_tags", "only_main_content",
2437
2438
  "wait_for", "timeout", "location", "mobile", "skip_tls_verification",
2438
2439
  "remove_base64_images", "block_ads", "proxy", "extract", "json_options",
2439
- "actions", "agent"},
2440
+ "actions", "agent", "webhook"},
2440
2441
  "batch_scrape_urls_and_watch": {"formats", "headers", "include_tags", "exclude_tags", "only_main_content",
2441
2442
  "wait_for", "timeout", "location", "mobile", "skip_tls_verification",
2442
2443
  "remove_base64_images", "block_ads", "proxy", "extract", "json_options",
2443
- "actions", "agent"}
2444
+ "actions", "agent", "webhook"}
2444
2445
  }
2445
2446
 
2446
2447
  # Get allowed parameters for this method
@@ -0,0 +1,213 @@
1
+ Metadata-Version: 2.1
2
+ Name: firecrawl
3
+ Version: 2.4.2
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: MIT License
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 :: MIT License
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
+ Requires-Dist: pydantic
41
+ Requires-Dist: aiohttp
42
+
43
+ # Firecrawl SDK
44
+
45
+ > Firecrawl SDK is a wrapper around the Firecrawl API to help you easily turn websites into markdown.
46
+
47
+ ## Installation
48
+
49
+ To install the Firecrawl SDK, you can use pip:
50
+
51
+ ```bash
52
+ pip install firecrawl-py
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ 1. Get an API key from [firecrawl.dev](https://firecrawl.dev)
58
+ 2. Set the API key as an environment variable named `FIRECRAWL_API_KEY` or pass it as a parameter to the `FirecrawlApp` class.
59
+
60
+ Here's an example of how to use the SDK:
61
+
62
+ ```python
63
+ from firecrawl import FirecrawlApp
64
+
65
+ app = FirecrawlApp(api_key="fc-YOUR_API_KEY")
66
+
67
+ # Scrape a website:
68
+ scrape_status = app.scrape_url(
69
+ 'https://firecrawl.dev',
70
+ formats=['markdown', 'html']
71
+ )
72
+ print(scrape_status)
73
+
74
+ # Crawl a website:
75
+ crawl_status = app.crawl_url(
76
+ 'https://firecrawl.dev',
77
+ limit=100,
78
+ scrape_options=ScrapeOptions(formats=['markdown', 'html'])
79
+ )
80
+ print(crawl_status)
81
+ ```
82
+
83
+ ### Scraping a URL
84
+
85
+ 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.
86
+
87
+ ```python
88
+ # Scrape a website:
89
+ scrape_result = app.scrape_url('firecrawl.dev', formats=['markdown', 'html'])
90
+ print(scrape_result)
91
+ ```
92
+
93
+ ### Crawling a Website
94
+
95
+ 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.
96
+
97
+ ```python
98
+ crawl_status = app.crawl_url(
99
+ 'https://firecrawl.dev',
100
+ limit=100,
101
+ scrape_options=ScrapeOptions(formats=['markdown', 'html']),
102
+ poll_interval=30
103
+ )
104
+ print(crawl_status)
105
+ ```
106
+
107
+ ### Asynchronous Crawling
108
+
109
+ <Tip>Looking for async operations? Check out the [Async Class](#async-class) section below.</Tip>
110
+
111
+ To crawl a website asynchronously, use the `crawl_url_async` method. It returns the crawl `ID` which you can use to check the status of the crawl job. 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.
112
+
113
+ ```python
114
+ crawl_status = app.async_crawl_url(
115
+ 'https://firecrawl.dev',
116
+ limit=100,
117
+ scrape_options=ScrapeOptions(formats=['markdown', 'html']),
118
+ )
119
+ print(crawl_status)
120
+ ```
121
+
122
+ ### Checking Crawl Status
123
+
124
+ 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.
125
+
126
+ ```python
127
+ crawl_status = app.check_crawl_status("<crawl_id>")
128
+ print(crawl_status)
129
+ ```
130
+
131
+ ### Cancelling a Crawl
132
+
133
+ To cancel an asynchronous crawl job, use the `cancel_crawl` method. It takes the job ID of the asynchronous crawl as a parameter and returns the cancellation status.
134
+
135
+ ```python
136
+ cancel_crawl = app.cancel_crawl(id)
137
+ print(cancel_crawl)
138
+ ```
139
+
140
+ ### Map a Website
141
+
142
+ 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.
143
+
144
+ ```python
145
+ # Map a website:
146
+ map_result = app.map_url('https://firecrawl.dev')
147
+ print(map_result)
148
+ ```
149
+
150
+ {/* ### Extracting Structured Data from Websites
151
+
152
+ To extract structured data from websites, use the `extract` method. It takes the URLs to extract data from, a prompt, and a schema as arguments. The schema is a Pydantic model that defines the structure of the extracted data.
153
+
154
+ <ExtractPythonShort /> */}
155
+
156
+ ### Crawling a Website with WebSockets
157
+
158
+ 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.
159
+
160
+ ```python
161
+ # inside an async function...
162
+ nest_asyncio.apply()
163
+
164
+ # Define event handlers
165
+ def on_document(detail):
166
+ print("DOC", detail)
167
+
168
+ def on_error(detail):
169
+ print("ERR", detail['error'])
170
+
171
+ def on_done(detail):
172
+ print("DONE", detail['status'])
173
+
174
+ # Function to start the crawl and watch process
175
+ async def start_crawl_and_watch():
176
+ # Initiate the crawl job and get the watcher
177
+ watcher = app.crawl_url_and_watch('firecrawl.dev', exclude_paths=['blog/*'], limit=5)
178
+
179
+ # Add event listeners
180
+ watcher.add_event_listener("document", on_document)
181
+ watcher.add_event_listener("error", on_error)
182
+ watcher.add_event_listener("done", on_done)
183
+
184
+ # Start the watcher
185
+ await watcher.connect()
186
+
187
+ # Run the event loop
188
+ await start_crawl_and_watch()
189
+ ```
190
+
191
+ ## Error Handling
192
+
193
+ 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.
194
+
195
+ ## Async Class
196
+
197
+ For async operations, you can use the `AsyncFirecrawlApp` class. Its methods are the same as the `FirecrawlApp` class, but they don't block the main thread.
198
+
199
+ ```python
200
+ from firecrawl import AsyncFirecrawlApp
201
+
202
+ app = AsyncFirecrawlApp(api_key="YOUR_API_KEY")
203
+
204
+ # Async Scrape
205
+ async def example_scrape():
206
+ scrape_result = await app.scrape_url(url="https://example.com")
207
+ print(scrape_result)
208
+
209
+ # Async Crawl
210
+ async def example_crawl():
211
+ crawl_result = await app.crawl_url(url="https://example.com")
212
+ print(crawl_result)
213
+ ```
@@ -1,12 +1,12 @@
1
- firecrawl/__init__.py,sha256=Gg99f51IOBHrpPWOVIXyuSbkZIKHLUw0JPQMU349ABw,2570
2
- firecrawl/firecrawl.py,sha256=aR6849XXWwsxBXrAIz-EAlVEkXggQyrW0mLGitgpieg,182692
1
+ firecrawl/__init__.py,sha256=IBkWDfJ36KBC5xDpjMPkZt1zCroMZh0HnbzfNmrch4U,2570
2
+ firecrawl/firecrawl.py,sha256=Q1opxN1JxjbWLEDsSS3P5aEm4f9LEJrZyhd8UdsMVFw,182769
3
3
  firecrawl/__tests__/e2e_withAuth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  firecrawl/__tests__/e2e_withAuth/test.py,sha256=-Fq2vPcMo0iQi4dwsUkkCd931ybDaTxMBnZbRfGdDcA,7931
5
5
  firecrawl/__tests__/v1/e2e_withAuth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  firecrawl/__tests__/v1/e2e_withAuth/test.py,sha256=DcCw-cohtnL-t9XPekUtRoQrgg3UCWu8Ikqudf9ory8,19880
7
7
  tests/test_change_tracking.py,sha256=_IJ5ShLcoj2fHDBaw-nE4I4lHdmDB617ocK_XMHhXps,4177
8
- firecrawl-2.4.0.dist-info/LICENSE,sha256=nPCunEDwjRGHlmjvsiDUyIWbkqqyj3Ej84ntnh0g0zA,1084
9
- firecrawl-2.4.0.dist-info/METADATA,sha256=f1WKYRlMDmMFkXN9hYqJZsDfXINtiDNQutiW0twRe0Y,10583
10
- firecrawl-2.4.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
11
- firecrawl-2.4.0.dist-info/top_level.txt,sha256=8T3jOaSN5mtLghO-R3MQ8KO290gIX8hmfxQmglBPdLE,16
12
- firecrawl-2.4.0.dist-info/RECORD,,
8
+ firecrawl-2.4.2.dist-info/LICENSE,sha256=nPCunEDwjRGHlmjvsiDUyIWbkqqyj3Ej84ntnh0g0zA,1084
9
+ firecrawl-2.4.2.dist-info/METADATA,sha256=FWoaLhnEXH4w-kENIp-bZZvX8P73dxhZH4izvlzKpic,7007
10
+ firecrawl-2.4.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
11
+ firecrawl-2.4.2.dist-info/top_level.txt,sha256=8T3jOaSN5mtLghO-R3MQ8KO290gIX8hmfxQmglBPdLE,16
12
+ firecrawl-2.4.2.dist-info/RECORD,,
@@ -1,293 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: firecrawl
3
- Version: 2.4.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: MIT License
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 :: MIT License
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
- Requires-Dist: pydantic
41
- Requires-Dist: aiohttp
42
-
43
- # Firecrawl Python SDK
44
-
45
- 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.
46
-
47
- ## Installation
48
-
49
- To install the Firecrawl Python SDK, you can use pip:
50
-
51
- ```bash
52
- pip install firecrawl-py
53
- ```
54
-
55
- ## Usage
56
-
57
- 1. Get an API key from [firecrawl.dev](https://firecrawl.dev)
58
- 2. Set the API key as an environment variable named `FIRECRAWL_API_KEY` or pass it as a parameter to the `FirecrawlApp` class.
59
-
60
- Here's an example of how to use the SDK:
61
-
62
- ```python
63
- from firecrawl.firecrawl import FirecrawlApp
64
-
65
- app = FirecrawlApp(api_key="fc-YOUR_API_KEY")
66
-
67
- # Scrape a website:
68
- scrape_status = app.scrape_url(
69
- 'https://firecrawl.dev',
70
- params={'formats': ['markdown', 'html']}
71
- )
72
- print(scrape_status)
73
-
74
- # Crawl a website:
75
- crawl_status = app.crawl_url(
76
- 'https://firecrawl.dev',
77
- params={
78
- 'limit': 100,
79
- 'scrapeOptions': {'formats': ['markdown', 'html']}
80
- },
81
- poll_interval=30
82
- )
83
- print(crawl_status)
84
- ```
85
-
86
- ### Scraping a URL
87
-
88
- 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.
89
-
90
- ```python
91
- url = 'https://example.com'
92
- scraped_data = app.scrape_url(url)
93
- ```
94
-
95
- ### Extracting structured data from a URL
96
-
97
- 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:
98
-
99
- ```python
100
- class ArticleSchema(BaseModel):
101
- title: str
102
- points: int
103
- by: str
104
- commentsURL: str
105
-
106
- class TopArticlesSchema(BaseModel):
107
- top: List[ArticleSchema] = Field(..., max_items=5, description="Top 5 stories")
108
-
109
- data = app.scrape_url('https://news.ycombinator.com', {
110
- 'extractorOptions': {
111
- 'extractionSchema': TopArticlesSchema.model_json_schema(),
112
- 'mode': 'llm-extraction'
113
- },
114
- 'pageOptions':{
115
- 'onlyMainContent': True
116
- }
117
- })
118
- print(data["llm_extraction"])
119
- ```
120
-
121
- ### Crawling a Website
122
-
123
- 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.
124
-
125
- ```python
126
- idempotency_key = str(uuid.uuid4()) # optional idempotency key
127
- crawl_result = app.crawl_url('firecrawl.dev', {'excludePaths': ['blog/*']}, 2, idempotency_key)
128
- print(crawl_result)
129
- ```
130
-
131
- ### Asynchronous Crawl a Website
132
-
133
- 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.
134
-
135
- ```python
136
- crawl_result = app.async_crawl_url('firecrawl.dev', {'excludePaths': ['blog/*']}, "")
137
- print(crawl_result)
138
- ```
139
-
140
- ### Checking Crawl Status
141
-
142
- 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.
143
-
144
- ```python
145
- id = crawl_result['id']
146
- status = app.check_crawl_status(id)
147
- ```
148
-
149
- ### Map a Website
150
-
151
- 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.
152
-
153
- ```python
154
- # Map a website:
155
- map_result = app.map_url('https://example.com')
156
- print(map_result)
157
- ```
158
-
159
- ### Crawl a website with WebSockets
160
-
161
- 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.
162
-
163
- ```python
164
- # inside an async function...
165
- nest_asyncio.apply()
166
-
167
- # Define event handlers
168
- def on_document(detail):
169
- print("DOC", detail)
170
-
171
- def on_error(detail):
172
- print("ERR", detail['error'])
173
-
174
- def on_done(detail):
175
- print("DONE", detail['status'])
176
-
177
- # Function to start the crawl and watch process
178
- async def start_crawl_and_watch():
179
- # Initiate the crawl job and get the watcher
180
- watcher = app.crawl_url_and_watch('firecrawl.dev', { 'excludePaths': ['blog/*'], 'limit': 5 })
181
-
182
- # Add event listeners
183
- watcher.add_event_listener("document", on_document)
184
- watcher.add_event_listener("error", on_error)
185
- watcher.add_event_listener("done", on_done)
186
-
187
- # Start the watcher
188
- await watcher.connect()
189
-
190
- # Run the event loop
191
- await start_crawl_and_watch()
192
- ```
193
-
194
- ### Scraping multiple URLs in batch
195
-
196
- 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.
197
-
198
- ```python
199
- idempotency_key = str(uuid.uuid4()) # optional idempotency key
200
- batch_scrape_result = app.batch_scrape_urls(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']}, 2, idempotency_key)
201
- print(batch_scrape_result)
202
- ```
203
-
204
- ### Asynchronous batch scrape
205
-
206
- 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.
207
-
208
- ```python
209
- batch_scrape_result = app.async_batch_scrape_urls(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']})
210
- print(batch_scrape_result)
211
- ```
212
-
213
- ### Checking batch scrape status
214
-
215
- 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.
216
-
217
- ```python
218
- id = batch_scrape_result['id']
219
- status = app.check_batch_scrape_status(id)
220
- ```
221
-
222
- ### Batch scrape with WebSockets
223
-
224
- 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.
225
-
226
- ```python
227
- # inside an async function...
228
- nest_asyncio.apply()
229
-
230
- # Define event handlers
231
- def on_document(detail):
232
- print("DOC", detail)
233
-
234
- def on_error(detail):
235
- print("ERR", detail['error'])
236
-
237
- def on_done(detail):
238
- print("DONE", detail['status'])
239
-
240
- # Function to start the crawl and watch process
241
- async def start_crawl_and_watch():
242
- # Initiate the crawl job and get the watcher
243
- watcher = app.batch_scrape_urls_and_watch(['firecrawl.dev', 'mendable.ai'], {'formats': ['markdown', 'html']})
244
-
245
- # Add event listeners
246
- watcher.add_event_listener("document", on_document)
247
- watcher.add_event_listener("error", on_error)
248
- watcher.add_event_listener("done", on_done)
249
-
250
- # Start the watcher
251
- await watcher.connect()
252
-
253
- # Run the event loop
254
- await start_crawl_and_watch()
255
- ```
256
-
257
- ## Error Handling
258
-
259
- 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.
260
-
261
- ## Running the Tests with Pytest
262
-
263
- 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.
264
-
265
- ### Running the Tests
266
-
267
- To run the tests, execute the following commands:
268
-
269
- Install pytest:
270
-
271
- ```bash
272
- pip install pytest
273
- ```
274
-
275
- Run:
276
-
277
- ```bash
278
- pytest firecrawl/__tests__/e2e_withAuth/test.py
279
- ```
280
-
281
- ## Contributing
282
-
283
- 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.
284
-
285
- ## License
286
-
287
- 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:
288
-
289
- - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
290
-
291
- 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.
292
-
293
- 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.