项目实战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

//img.mukewang.com/szimg/5dea225409c8bd2a09640366.jpg 从错误站来看是这一行出错了 是因为all_divs是空列表 你可以debug看一下为什么会是空列表

0
0

Python爬虫工程师实战 大数据时代必备

慕课网严选精品教程,高质量内容+服务!

2378 学习 · 1158 问题

查看课程