Closed iseesaw closed 4 years ago
这个我没能复现成功,comment_list应该是dict,我爬你声明的这个帖子也确实是dict。被解析为list有可能是网络波动造成内容读取错误吧,应该是偶然事件。
如果在你那边可以稳定复现的话,能否帮忙调试看看comment_list具体是什么?就是在你的"/root/Tieba_Spider/tieba/spiders/tieba_spider.py"的第82行(即for value in comment_list.values():
)的前面加几行,这一块变成下面这个样子
def parse_comment(self, response):
comment_list = json.loads(response.body.decode('utf8'))['data']['comment_list']
if type(comment_list) == list:
print("Response Body: ")
print(response.body)
print("Comment List: ")
print(comment_list)
for value in comment_list.values():
...
这样一来在报错信息的前面就可以看到变量具体内容是什么。
Ok,我试试,爬了十来个贴吧,有两三个出现这个问题了
没法稳定复现呢
16:34 开始运行的