dataabc / weiboSpider

新浪微博爬虫,用python爬取新浪微博数据
8.37k stars 1.98k forks source link

list index out of range #356

Closed XiaoQB closed 3 years ago

XiaoQB commented 3 years ago

github版本,macOS,设置完成后第一次运行,报如下错误:

list index out of range Traceback (most recent call last): File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/parser/info_parser.py", line 39, in extract_user_info if self.selector.xpath( IndexError: list index out of range 'NoneType' object has no attribute 'id' Traceback (most recent call last): File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/parser/index_parser.py", line 36, in get_user self.user.id = user_id AttributeError: 'NoneType' object has no attribute 'id' None


'NoneType' object has no attribute 'nickname' Traceback (most recent call last): File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/spider.py", line 215, in _get_filepath dir_name = self.user.nickname AttributeError: 'NoneType' object has no attribute 'nickname' expected str, bytes or os.PathLike object, not NoneType Traceback (most recent call last): File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/writer/csv_writer.py", line 25, in init with open(self.file_path, 'a', encoding='utf-8-sig', TypeError: expected str, bytes or os.PathLike object, not NoneType 'NoneType' object has no attribute 'nickname' Traceback (most recent call last): File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/spider.py", line 215, in _get_filepath dir_name = self.user.nickname AttributeError: 'NoneType' object has no attribute 'nickname' 'NoneType' object has no attribute 'dict' Traceback (most recent call last): File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/spider.py", line 302, in get_one_user self.write_user(self.user) File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/spider.py", line 136, in write_user writer.write_user(user) File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/writer/txt_writer.py", line 29, in write_user [v + ':' + str(self.user.dict[k]) for k, v in self.user_desc]) File "/Users/xiaoqb/weibo_autoSurfing/weiboSpider/weibo_spider/writer/txt_writer.py", line 29, in [v + ':' + str(self.user.dict[k]) for k, v in self.user_desc]) AttributeError: 'NoneType' object has no attribute 'dict'

dataabc commented 3 years ago

感谢反馈。这是速度太快暂时被限制了,参考常见问题问题2,如果还有问题欢迎继续讨论。

XiaoQB commented 3 years ago

感谢及时解答!