Setup

Installation

pip install zyte-common-items

Scrapy configuration

If you use Scrapy, zyte-common-items provides some functionality that needs configuring:

itemadapter configuration

Tip

You do not need to set this manually if you are using the Scrapy add-on.

To allow itemadapter 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.