Adapter
- class zyte_common_items.ZyteItemAdapter(item: Any)
Wrap an item to interact with its content as if it was a dictionary.
It can be configured into itemadapter to improve interaction with items for itemadapter users like Scrapy.
In extends AttrsAdapter with the following features:
Allows interaction and serialization of fields from
_unknown_fields_dict
as if they were regular item fields.Removes keys with empty values from the output of ItemAdapter.asdict(), for a cleaner output.
- class zyte_common_items.ZyteItemKeepEmptyAdapter(item: Any)
Similar to
ZyteItemAdapter
but doesn’t remove empty values.It is intended to be used in tests and other use cases where it’s important to differentiate between empty and missing fields.