mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 07:59:14 +08:00
Nick: fix extract python sdk
This commit is contained in:
parent
dbda659e71
commit
ea1d3d7025
@ -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")
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user