I am pretty new scrapy and here I need some help regarding image url that is in the data-src .... Here is my code....
from typing import Text
import scrapy
class SeamsSpider(scrapy.Spider):
name = 'seams'
start_urls = [
'https://in.seamsfriendly.com/collections/shorts'
]
def parse(self, response):
title : response.css("#shopify-section-collection-template a::text").extract()
price : response.css(".Price::text").extract()
url : response.css("img.data-src::text").extract()
I am not getting any output using the above , please help me in this
CodePudding user response:
Similar to suffix ::text
for extracting text content from a selector, we have also the suffix ::attr(attribute_name)
for extract the value for a given attribute. In your case, in order to get the content within data-src
attribute you can usse the following selector:
response.css("img::attr(data-src)").extract()
I hope it suits you well :)