Skip to content

Commit

Permalink
ZyteApiProvider: support more data types
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Jul 12, 2023
1 parent a3f3e15 commit 5ad4d79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 22 additions & 3 deletions scrapy_zyte_api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit 5ad4d79

Please sign in to comment.