Answers for "scrapy css selector"

1

get href scrapy xpath

# with xpath
//div[@class='image']/a[1]/@href

# using css
Link = response.css('span.title a::attr(href)').getall()
Posted by: Guest on May-05-2020
1

scrapy get inside attribute value

#Given 
<time datetime="2020-09-01T11:48:24-03:00" itemprop="datePublished">a given text</time>

# to get the attribute value datetime:
getData = response.css('time::attr(datetime)').get()

# output
'2020-09-01T11:48:24-03:00'
Posted by: Guest on September-01-2020
0

scrapy get raw html content of selector innerhtml

response.xpath('//*').get()
Posted by: Guest on May-11-2020

Python Answers by Framework

Browse Popular Code Answers by Language