Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick: fix extract python sdk

Nicolasea1d3d7025ca
diff --git a/apps/python-sdk/firecrawl/__init__.py b/apps/python-sdk/firecrawl/__init__.py
index d39b77a81..270befb2e 100644
--- a/apps/python-sdk/firecrawl/__init__.py
+++ b/apps/python-sdk/firecrawl/__init__.py
@@ -13,7 +13,7 @@ import os
from .firecrawl import FirecrawlApp # noqa
-__version__ = "1.6.0"
+__version__ = "1.6.1"
# Define the logger for the Firecrawl project
logger: logging.Logger = logging.getLogger("firecrawl")
diff --git a/apps/python-sdk/firecrawl/firecrawl.py b/apps/python-sdk/firecrawl/firecrawl.py
index bb87906c1..a973e2800 100644
--- a/apps/python-sdk/firecrawl/firecrawl.py
+++ b/apps/python-sdk/firecrawl/firecrawl.py
@@ -39,13 +39,6 @@ class FirecrawlApp:
data: Optional[Any] = None
error: Optional[str] = None
- class ErrorResponse(pydantic.BaseModel):
- """
- Error response.
- """
- success: bool
- error: str
-
def __init__(self, api_key: Optional[str] = None, api_url: Optional[str] = None) -> None:
"""
Initialize the FirecrawlApp instance with API key, API URL.
@@ -460,7 +453,7 @@ class FirecrawlApp:
self._handle_error(response, 'check batch scrape status')
- def extract(self, urls: List[str], params: Optional[ExtractParams] = None) -> Union[ExtractResponse, ErrorResponse]:
+ def extract(self, urls: List[str], params: Optional[ExtractParams] = None) -> Any:
"""
Extracts information from a URL using the Firecrawl API.
@@ -493,7 +486,11 @@ class FirecrawlApp:
headers
)
if response.status_code == 200:
- return response.json()
+ data = response.json()
+ if data['success']:
+ return data
+ else:
+ raise Exception(f'Failed to extract. Error: {data["error"]}')
else:
self._handle_error(response, "extract")
except Exception as e: