当我启动蜘蛛时,我收到了这个NoneType错误:
如果tab_arrivee_th: TypeError:类型为'NoneType‘的参数不可迭代
在控制台测试中,代码在list中工作得很好,但在response.css中却不起作用。我认为这个问题来自于response_arrivee_th,我不明白为什么,因为'scrapy shell‘给了我一个列表作为回报,这和我在测试中使用的一样。
def parse(self, response):
tab_arrivee_th = response.css('.arrivees th::text').extract()
# list obtained whit the response.css from above in scrapy shell
# tab_arrivee_th = ['Cl.', 'N°', 'Cheval', 'S/A', 'Œill.', 'Poids', 'Corde', 'Ecart', 'Jockey', 'Entraîneur', 'Tx', 'Récl.', 'Rapp. Ouv.']
if 'Jockey' in tab_arrivee_th:
col_jockey = tab_arrivee_th.index('Jockey') + 1
elif 'Driver' in tab_arrivee_th:
col_jockey = tab_arrivee_th.index('Driver') + 1
else:
col_jockey = 0
jockey = partant.css('td:nth-child(' + str(col_jockey) + ') > a::text').extract()如果tab_arrivee_th: TypeError:类型为'NoneType‘的参数不可迭代
thx寻求帮助
发布于 2019-07-22 12:19:42
Response.css(‘.arrivees th::text’).extract()指向js中的列表结构。
所以我用刮溅法延迟了0.5秒。而且效果很好。
发布于 2019-07-22 10:45:39
此行tab_arrivee_th = response.css('.arrivees th::text').extract()的响应为空,请再次检查响应。
https://stackoverflow.com/questions/57144159
复制相似问题