Scrapy Items - Scrapy

What are Scrapy Items?

Description

Scrapy process is used for extracting the data from sources like web pages using the spiders. Scrapy uses Item class for producing the output whose objects are used to gather the scraped data.

Declaring Items

Items can be declared using the class definition syntax along with the field objects shown as follows

Item Fields

Item fields are used for displaying the metadata for each field. As there is no limitation of values on the field objects, accessible metadata keys will not contain any reference list of metadata. The field objects are used for specifying all the field metadata and any other field key can be specified based on your requirement in the project. Field objects can be accessed using the Item.fields attribute.

Working with Items

There are some common functions which can be defined when you are working with the items. For more information, click this link.

Extending Items

Items can be extended by stating the subclass of the original item. For instance

Existing field metadata can be used to extend the field metadata by adding more values or changing the existing values as shown in below code

Item Objects

Item objects can be specified using below class which provides the new initialized item from the given argument

Item will provide a copy of the constructor and provides an extra attribute which is given by the items in the fields.

Field Objects

Field objects can be specified using below class in which the Field class doesn't issue the additional process or attributes

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Scrapy Topics