默认 · May 9, 2022 0

scrapy使用css选择器筛选图片地址

Table of Content

css选择器的使用也蛮好用的
As you can see, .xpath() and .css() methods return a SelectorList instance, which is a list of new selectors. This API can be used for quickly selecting nested data:

response.css('img').xpath('@src').getall()
['image1_thumb.jpg',
 'image2_thumb.jpg',
 'image3_thumb.jpg',
 'image4_thumb.jpg',
 'image5_thumb.jpg']

参考链接
https://docs.scrapy.org/en/latest/topics/selectors.html

%d bloggers like this: