firecrawl 1.2.3__py3-none-any.whl → 1.3.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.

firecrawl/__init__.py CHANGED
@@ -13,7 +13,7 @@ import os
13
13
 
14
14
  from .firecrawl import FirecrawlApp
15
15
 
16
- __version__ = "1.2.3"
16
+ __version__ = "1.3.0"
17
17
 
18
18
  # Define the logger for the Firecrawl project
19
19
  logger: logging.Logger = logging.getLogger("firecrawl")
firecrawl/firecrawl.py CHANGED
@@ -13,7 +13,6 @@ import logging
13
13
  import os
14
14
  import time
15
15
  from typing import Any, Dict, Optional, List
16
- import asyncio
17
16
  import json
18
17
 
19
18
  import requests
@@ -192,6 +191,23 @@ class FirecrawlApp:
192
191
  }
193
192
  else:
194
193
  self._handle_error(response, 'check crawl status')
194
+
195
+ def cancel_crawl(self, id: str) -> Dict[str, Any]:
196
+ """
197
+ Cancel an asynchronous crawl job using the Firecrawl API.
198
+
199
+ Args:
200
+ id (str): The ID of the crawl job to cancel.
201
+
202
+ Returns:
203
+ Dict[str, Any]: The response from the cancel crawl request.
204
+ """
205
+ headers = self._prepare_headers()
206
+ response = self._delete_request(f'{self.api_url}/v1/crawl/{id}', headers)
207
+ if response.status_code == 200:
208
+ return response.json()
209
+ else:
210
+ self._handle_error(response, "cancel crawl job")
195
211
 
196
212
  def crawl_url_and_watch(self, url: str, params: Optional[Dict[str, Any]] = None, idempotency_key: Optional[str] = None) -> 'CrawlWatcher':
197
213
  """
@@ -229,7 +245,7 @@ class FirecrawlApp:
229
245
  json_data = {'url': url}
230
246
  if params:
231
247
  json_data.update(params)
232
-
248
+
233
249
  # Make the POST request with the prepared headers and JSON data
234
250
  response = requests.post(
235
251
  f'{self.api_url}{endpoint}',
@@ -239,7 +255,7 @@ class FirecrawlApp:
239
255
  if response.status_code == 200:
240
256
  response = response.json()
241
257
  if response['success'] and 'links' in response:
242
- return response['links']
258
+ return response
243
259
  else:
244
260
  raise Exception(f'Failed to map URL. Error: {response["error"]}')
245
261
  else:
@@ -322,6 +338,33 @@ class FirecrawlApp:
322
338
  else:
323
339
  return response
324
340
  return response
341
+
342
+ def _delete_request(self, url: str,
343
+ headers: Dict[str, str],
344
+ retries: int = 3,
345
+ backoff_factor: float = 0.5) -> requests.Response:
346
+ """
347
+ Make a DELETE request with retries.
348
+
349
+ Args:
350
+ url (str): The URL to send the DELETE request to.
351
+ headers (Dict[str, str]): The headers to include in the DELETE request.
352
+ retries (int): Number of retries for the request.
353
+ backoff_factor (float): Backoff factor for retries.
354
+
355
+ Returns:
356
+ requests.Response: The response from the DELETE request.
357
+
358
+ Raises:
359
+ requests.RequestException: If the request fails after the specified retries.
360
+ """
361
+ for attempt in range(retries):
362
+ response = requests.delete(url, headers=headers)
363
+ if response.status_code == 502:
364
+ time.sleep(backoff_factor * (2 ** attempt))
365
+ else:
366
+ return response
367
+ return response
325
368
 
326
369
  def _monitor_job_status(self, id: str, headers: Dict[str, str], poll_interval: int) -> Any:
327
370
  """
@@ -435,4 +478,4 @@ class CrawlWatcher:
435
478
  self.dispatch_event('document', doc)
436
479
  elif msg['type'] == 'document':
437
480
  self.data.append(msg['data'])
438
- self.dispatch_event('document', msg['data'])
481
+ self.dispatch_event('document', msg['data'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: firecrawl
3
- Version: 1.2.3
3
+ Version: 1.3.0
4
4
  Summary: Python SDK for Firecrawl API
5
5
  Home-page: https://github.com/mendableai/firecrawl
6
6
  Author: Mendable.ai
@@ -36,7 +36,6 @@ License-File: LICENSE
36
36
  Requires-Dist: requests
37
37
  Requires-Dist: python-dotenv
38
38
  Requires-Dist: websockets
39
- Requires-Dist: asyncio
40
39
  Requires-Dist: nest-asyncio
41
40
 
42
41
  # Firecrawl Python SDK
@@ -0,0 +1,11 @@
1
+ firecrawl/__init__.py,sha256=PLBoKqU5OAidzN7dJSD96fjhO6dzeJr0M13p2A9-6co,1682
2
+ firecrawl/firecrawl.py,sha256=aCJ-UMOnt35AiOVAe9kobUFjaS-K81mMKe49TZAKB-4,19175
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.3.0.dist-info/LICENSE,sha256=nPCunEDwjRGHlmjvsiDUyIWbkqqyj3Ej84ntnh0g0zA,1084
8
+ firecrawl-1.3.0.dist-info/METADATA,sha256=EGLvZGl6JyT3iBgx9YEBRr1NCiaiL859YYGlxc6JppU,8274
9
+ firecrawl-1.3.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
10
+ firecrawl-1.3.0.dist-info/top_level.txt,sha256=jTvz79zWhiyAezfmmHe4FQ-hR60C59UU5FrjMjijLu8,10
11
+ firecrawl-1.3.0.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- firecrawl/__init__.py,sha256=EBvu6gf8rvsrcmzwQJq-V_TIM7T50PWwzM1byNwBsUs,1682
2
- firecrawl/firecrawl.py,sha256=sL8YE89d4GI5CNXLfhDB4Xs4nbyImvarKIk6O19aaPg,17583
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.2.3.dist-info/LICENSE,sha256=nPCunEDwjRGHlmjvsiDUyIWbkqqyj3Ej84ntnh0g0zA,1084
8
- firecrawl-1.2.3.dist-info/METADATA,sha256=PHZfjDvfaKEqBOZdziuFwHnMGJ5wc8X5kuZNle6HvuE,8297
9
- firecrawl-1.2.3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
10
- firecrawl-1.2.3.dist-info/top_level.txt,sha256=jTvz79zWhiyAezfmmHe4FQ-hR60C59UU5FrjMjijLu8,10
11
- firecrawl-1.2.3.dist-info/RECORD,,