Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Search: remove the max_requests widget #87

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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