繁体   English   中英

Scrapy错误:“ NoneType”对象没有属性“ strip”

[英]Scrapy error : 'NoneType' object has no attribute 'strip'

我正在使用scrapy 1.4twisted的版本是17.5.0 ,python是3.6.3

html是这样的:

<span class="number">   20</span>

当我运行蜘蛛时,出现错误:

item['number'] = response.xpath('//span[@class="number"]/text()').extract_first().strip()
AttributeError: 'NoneType' object has no attribute 'strip'

我该怎么办?

似乎问题出在您编写的xpath或文档本身中。 如果找不到匹配项, extract_first方法将返回None 我已经在在线xpath验证程序中检查了您的示例,似乎一切都很好

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM