【发布时间】:2019-07-22 10:35:42
【问题描述】:
Whit scrapy,当我启动我的蜘蛛时,我收到了这个NoneType 错误:
如果 tab_arrivee_th 中的“Jockey”: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 中的“Jockey”:TypeError:“NoneType”类型的参数 不可迭代
感谢帮助
【问题讨论】: