Setup
Installation
pip install zyte-common-items
Configuration
To allow itemadapter users, like Scrapy, to interact with items, prepend ZyteItemAdapter
or
ZyteItemKeepEmptyAdapter
to
itemadapter.ItemAdapter.ADAPTER_CLASSES as early as possible in your code:
from itemadapter import ItemAdapter
from zyte_common_items import ZyteItemAdapter
ItemAdapter.ADAPTER_CLASSES.appendleft(ZyteItemAdapter)
Alternatively, make your own subclass of itemadapter.ItemAdapter
:
from collections import deque
from itemadapter import ItemAdapter
from zyte_common_items import ZyteItemAdapter
class MyItemAdapter(ItemAdapter):
ADAPTER_CLASSES = deque([ZyteItemAdapter]) + ItemAdapter.ADAPTER_CLASSES
Now you can use MyItemAdapter
where you would use
itemadapter.ItemAdapter
.