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

Published on Aug. 22, 2023, 12:11 p.m.

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

Tags: