Skip to content

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

(python-sdk)fix/max_pages (#2527)

Rafael Miller02d9b5fe0c71
diff --git a/apps/python-sdk/firecrawl/__init__.py b/apps/python-sdk/firecrawl/__init__.py
index 5459d1008..059001f9e 100644
--- a/apps/python-sdk/firecrawl/__init__.py
+++ b/apps/python-sdk/firecrawl/__init__.py
@@ -17,7 +17,7 @@ from .v1 import (
V1ChangeTrackingOptions,
)
-__version__ = "4.10.3"
+__version__ = "4.10.4"
# Define the logger for the Firecrawl project
logger: logging.Logger = logging.getLogger("firecrawl")
diff --git a/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_request_preparation.py b/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_request_preparation.py
index 1ff57f260..a2aebef42 100644
--- a/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_request_preparation.py
+++ b/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_request_preparation.py
@@ -14,7 +14,7 @@ class TestSearchRequestPreparation:
# Check basic fields
assert data["query"] == "test query"
assert data["limit"] == 5
- assert data["timeout"] == 60000
+ assert data["timeout"] == 300000
# Check that snake_case fields are not present
assert "ignore_invalid_urls" not in data
diff --git a/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py b/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py
index fd58c9f58..242469573 100644
--- a/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py
+++ b/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py
@@ -208,7 +208,7 @@ class TestSearchRequestModel:
request = SearchRequest(query="test")
assert request.limit == 5
assert request.ignore_invalid_urls is None # No default in model
- assert request.timeout == 60000
+ assert request.timeout == 300000
assert request.sources is None
assert request.tbs is None
assert request.location is None
diff --git a/apps/python-sdk/firecrawl/__tests__/unit/v2/utils/test_validation.py b/apps/python-sdk/firecrawl/__tests__/unit/v2/utils/test_validation.py
index 653506af0..9842cd1a3 100644
--- a/apps/python-sdk/firecrawl/__tests__/unit/v2/utils/test_validation.py
+++ b/apps/python-sdk/firecrawl/__tests__/unit/v2/utils/test_validation.py
@@ -1,5 +1,5 @@
import pytest
-from firecrawl.v2.types import JsonFormat, ScrapeOptions
+from firecrawl.v2.types import JsonFormat, ScrapeOptions, PDFParser
from firecrawl.v2.utils.validation import validate_scrape_options, prepare_scrape_options
@@ -287,4 +287,25 @@ class TestPrepareScrapeOptions:
assert "use_mock" not in result
assert "block_ads" not in result
assert "store_in_cache" not in result
- assert "max_age" not in result
\ No newline at end of file
+ assert "max_age" not in result
+
+ def test_prepare_parsers_max_pages_dict(self):
+ """Ensure parser dicts convert max_pages to maxPages."""
+ options = ScrapeOptions(
+ parsers=[{"type": "pdf", "max_pages": 3}]
+ )
+
+ result = prepare_scrape_options(options)
+
+ assert "parsers" in result
+ assert result["parsers"][0]["maxPages"] == 3
+ assert "max_pages" not in result["parsers"][0]
+
+ def test_prepare_parsers_max_pages_model(self):
+ """Ensure parser models convert max_pages to maxPages."""
+ parser = PDFParser(max_pages=5)
+ options = ScrapeOptions(parsers=[parser])
+
+ result = prepare_scrape_options(options)
+
+ assert result["parsers"][0]["maxPages"] == 5
\ No newline at end of file
diff --git a/apps/python-sdk/firecrawl/v2/utils/validation.py b/apps/python-sdk/firecrawl/v2/utils/validation.py
index 530884954..4e5fd2c1b 100644
--- a/apps/python-sdk/firecrawl/v2/utils/validation.py
+++ b/apps/python-sdk/firecrawl/v2/utils/validation.py
@@ -668,7 +668,10 @@ def prepare_scrape_options(options: Optional[ScrapeOptions]) -> Optional[Dict[st
if isinstance(parser, str):
converted_parsers.append(parser)
elif isinstance(parser, dict):
- converted_parsers.append(parser)
+ parser_data = dict(parser)
+ if "max_pages" in parser_data:
+ parser_data["maxPages"] = parser_data.pop("max_pages")
+ converted_parsers.append(parser_data)
else:
parser_data = parser.model_dump(exclude_none=True)
# Convert snake_case to camelCase for API