You can download this code by clicking the button below.
This code is now available for download.
This function extracts the item title and price from a provided selector and returns them as a dictionary.
Technology Stack : Scrapy, CSS selectors
Code Type : Scrapy crawler handler
Code Difficulty : Intermediate
def parse_item(item, selector):
# Extract the item title and price from the provided selector
title = selector.css('h1.title::text').get()
price = selector.css('span.price::text').get()
# Return a dictionary with the extracted data
return {
'title': title,
'price': price
}