使用scrapy的response.replace()过滤特殊符号,爬取tmall店铺商品链接_scrapy 爬取网页时包含 a 标签的span 标签被过滤掉了-CSDN博客

网站介绍:文章浏览阅读1.1k次。抓取网页有时候会含有一些特殊符号,如, \r, \t, \n等,在使用xpth时会导致定位不到元素,此时就需要先对响应内容做一下过滤,然后使用response.replace()将过滤后的文档重新赋值给response# replace源码部分def replace(self, *args, **kwargs): """Create a new Response with the same attributes except for those given new values. ""_scrapy 爬取网页时包含 a 标签的span 标签被过滤掉了