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 2 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
1 change: 0 additions & 1 deletion tests/test_serp.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def test_metadata():
"and do not increase the request count in Scrapy Cloud."
),
"title": "Max Requests",
"widget": "request-limit",
},
},
"required": ["search_queries"],
Expand Down
17 changes: 15 additions & 2 deletions zyte_spider_templates/spiders/serp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from w3lib.url import add_or_replace_parameter
from zyte_common_items import Serp

from ..params import MaxRequestsParam
from ._google_domains import GoogleDomain
from .base import BaseSpider

Expand Down Expand Up @@ -48,6 +47,20 @@ 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,
Gallaecio marked this conversation as resolved.
Show resolved Hide resolved
)


class GoogleDomainParam(BaseModel):
domain: GoogleDomain = Field(
title="Domain",
Expand All @@ -57,7 +70,7 @@ class GoogleDomainParam(BaseModel):


class GoogleSearchSpiderParams(
MaxRequestsParam,
SerpMaxRequestsParam,
SerpMaxPagesParam,
SearchQueriesParam,
GoogleDomainParam,
Expand Down