From a5f3be41c1c097392ab4cb6035c95338373892e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Wed, 13 Nov 2024 07:54:18 +0100 Subject: [PATCH] Disable subcategory crawling with search queries --- zyte_spider_templates/spiders/ecommerce.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zyte_spider_templates/spiders/ecommerce.py b/zyte_spider_templates/spiders/ecommerce.py index 41b4e90..dff285f 100644 --- a/zyte_spider_templates/spiders/ecommerce.py +++ b/zyte_spider_templates/spiders/ecommerce.py @@ -170,6 +170,7 @@ def validate_direct_item_and_search_queries(self): if self.search_queries and self.crawl_strategy in { EcommerceCrawlStrategy.direct_item, EcommerceCrawlStrategy.full, + EcommerceCrawlStrategy.navigation, }: raise ValueError( f"Cannot combine the {self.crawl_strategy.value!r} value of " @@ -311,7 +312,10 @@ def parse_navigation( else: yield self.get_nextpage_request(navigation.nextPage) - if self.args.crawl_strategy != EcommerceCrawlStrategy.pagination_only: + if ( + self.args.crawl_strategy != EcommerceCrawlStrategy.pagination_only + and not self.args.search_queries + ): for request in navigation.subCategories or []: yield self.get_subcategory_request(request, page_params=page_params)