Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i fetch 'img' src attribute by scrapy?

Tags:

scrapy

I wanna to use scrapy to fetch the img's links so i write the program below in scrapy's crawler:

hxs.select('//dl[@class="clearfix"]//img/@src/text()').extract()

However, it's doesn't work anyway. is there any problem ?

like image 400
uuball Avatar asked Apr 21 '13 03:04

uuball


1 Answers

If you are using CSS selectors instead of XPath, the syntax is ::attr(src)

response.css('.product-list img::attr(src)').extract() # extract_first() to get only one
like image 142
user Avatar answered Sep 20 '22 23:09

user