Reputation: 4232
I am using scrapy 1.4
,the version of twisted
is 17.5.0
,python is 3.6.3
.
html is like this:
<span class="number"> 20</span>
when I run the spider,there is an error:
item['number'] = response.xpath('//span[@class="number"]/text()').extract_first().strip()
AttributeError: 'NoneType' object has no attribute 'strip'
what should I do?
Upvotes: 0
Views: 1465
Reputation: 51
Seems like problem is in the xpath that you wrote or in the document itself. extract_first
method returns None
if no match found. I've checked your example in online xpath validators and seems like everything is fine
Upvotes: 1