Skip to content

Commit

Permalink
Google Search: remove the max_requests widget (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio authored Nov 22, 2024
1 parent 8e0eefb commit 870e7ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions tests/test_serp.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def test_metadata():
"widget": "textarea",
},
"max_requests": {
"anyOf": [{"type": "integer"}, {"type": "null"}],
"anyOf": [{"type": "integer", "minimum": 1}, {"type": "null"}],
"default": 100,
"description": (
"The maximum number of Zyte API requests allowed for the crawl.\n"
Expand All @@ -302,7 +302,6 @@ def test_metadata():
"and do not increase the request count in Scrapy Cloud."
),
"title": "Max Requests",
"widget": "request-limit",
},
"max_pages": {
"default": 1,
Expand Down
18 changes: 16 additions & 2 deletions zyte_spider_templates/spiders/serp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from .._geolocations import GEOLOCATION_OPTIONS_WITH_CODE, Geolocation
from ..documentation import document_enum
from ..params import MaxRequestsParam
from ._google_domains import GoogleDomain
from ._google_gl import GOOGLE_GL_OPTIONS_WITH_CODE, GoogleGl
from ._google_hl import GOOGLE_HL_OPTIONS_WITH_CODE, GoogleHl
Expand Down Expand Up @@ -144,6 +143,21 @@ class SerpMaxPagesParam(BaseModel):
)


# MaxRequestsParam without the widget.
class SerpMaxRequestsParam(BaseModel):
max_requests: Optional[int] = Field(
description=(
"The maximum number of Zyte API requests allowed for the crawl.\n"
"\n"
"Requests with error responses that cannot be retried or exceed "
"their retry limit also count here, but they incur in no costs "
"and do not increase the request count in Scrapy Cloud."
),
default=100,
ge=1,
)


class SerpResultsPerPageParam(BaseModel):
results_per_page: Optional[int] = Field(
title="Results Per Page",
Expand Down Expand Up @@ -226,7 +240,7 @@ class GoogleSearchSpiderParams(
SerpItemTypeParam,
SerpResultsPerPageParam,
SerpMaxPagesParam,
MaxRequestsParam,
SerpMaxRequestsParam,
SearchQueriesParam,
GoogleDomainParam,
BaseModel,
Expand Down

0 comments on commit 870e7ef

Please sign in to comment.