项目实战1 - 论坛网站,实现静态网页数据抓取报错
来源:14-11 获取和解析列表页 - 2

慕娘6273471
2019-12-05
我按照老师新增的爬虫内容加进去,运行出错。怎么破?
/Users/kouurei/venv/bin/python /Users/kouurei/PycharmProjects/spider/csdn_spider/spider.py
/Users/kouurei/venv/lib/python3.7/site-packages/pymysql/cursors.py:170: Warning: (1292, “Truncated incorrect DOUBLE value: ’ '”)
result = self._query(query)
Traceback (most recent call last):
File “/Users/kouurei/PycharmProjects/spider/csdn_spider/spider.py”, line 214, in
parse_list(url)
File “/Users/kouurei/PycharmProjects/spider/csdn_spider/spider.py”, line 191, in parse_list
parse_topic(topic_url)
File “/Users/kouurei/PycharmProjects/spider/csdn_spider/spider.py”, line 67, in parse_topic
topic_item = all_divs[0]
File “/Users/kouurei/venv/lib/python3.7/site-packages/parsel/selector.py”, line 61, in getitem
o = super(SelectorList, self).getitem(pos)
IndexError: list index out of range
1回答
-
bobby
2019-12-06
从错误站来看是这一行出错了 是因为all_divs是空列表 你可以debug看一下为什么会是空列表
00
相似问题