项目场景:
scrapy 报错:AttributeError: ‘SelectorList’ object has no attribute ‘gatall’
问题描述:
用xpath 提取数据
data = response.xpath('//*[@id="content"]/text()').getall()
print(data)
response.xpath(’//*[@id=“content”]/text()’)返回的数据是
[<Selector xpath='//*[@id="content"]//text()' data='\r\n'>]
解决方案:
用extract() 去访问
data = response.xpath('//*[@id="content"]/text()').extract()