From 5ad4d7944d1dc2379e59afd5590d10be33faf5e2 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Wed, 12 Jul 2023 17:44:37 +0500 Subject: [PATCH] ZyteApiProvider: support more data types --- scrapy_zyte_api/providers.py | 25 ++++++++++++++++++++++--- setup.py | 2 +- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/scrapy_zyte_api/providers.py b/scrapy_zyte_api/providers.py index 26359a85..e76caa9e 100644 --- a/scrapy_zyte_api/providers.py +++ b/scrapy_zyte_api/providers.py @@ -6,7 +6,10 @@ from scrapy.utils.defer import maybe_deferred_to_future from scrapy_poet import PageObjectInputProvider from web_poet import BrowserHtml, BrowserResponse -from zyte_common_items import Product +from zyte_common_items import ( + Product, ProductList, ProductNavigation, + Article, ArticleList, ArticleNavigation +) from scrapy_zyte_api.responses import ZyteAPITextResponse @@ -20,7 +23,16 @@ class ZyteApiProvider(PageObjectInputProvider): name = "zyte_api" - provided_classes = {BrowserResponse, BrowserHtml, Product} + provided_classes = { + BrowserResponse, + BrowserHtml, + Product, + ProductList, + ProductNavigation, + Article, + ArticleList, + ArticleNavigation + } def __init__(self, injector): super().__init__(injector) @@ -47,7 +59,14 @@ async def __call__( return results html_requested = BrowserResponse in to_provide or BrowserHtml in to_provide - item_keywords = {Product: "product"} + item_keywords = { + Product: "product", + ProductList: "productList", + ProductNavigation: "productNavigation", + Article: "article", + ArticleList: "articleList", + ArticleNavigation: "articleNavigation", + } zyte_api_meta = {} if html_requested: diff --git a/setup.py b/setup.py index 6c340a2d..a4109ae5 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "provider": [ "scrapy-poet>=0.9.0", "web-poet>=0.13.0", - "zyte-common-items", + "zyte-common-items>=0.7.0", ] }, classifiers=[