dataabc / weiboSpider

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

NoneType报错 #443

Closed choudewanmei closed 2 years ago

choudewanmei commented 2 years ago

为了更好的解决问题,请认真回答下面的问题。等到问题解决,请及时关闭本issue。

答:pip

答:是

答:是

答:https://weibo.com/u/7166086720

答:7166086720;2021-10-01

答:invalid literal for int() with base 10: '7.2万'

Traceback (most recent call last): File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\parser\index_parser.py", line 41, in get_user self.user.followers = int(user_info[2][3:-1]) ValueError: invalid literal for int() with base 10: '7.2万' None


'NoneType' object has no attribute 'nickname' Traceback (most recent call last): File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 226, 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 "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\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 "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 226, in _get_filepath dir_name = self.user.nickname AttributeError: 'NoneType' object has no attribute 'nickname' 'NoneType' object has no attribute 'nickname' Traceback (most recent call last): File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 226, in _get_filepath dir_name = self.user.nickname AttributeError: 'NoneType' object has no attribute 'nickname' 'NoneType' object has no attribute 'nickname' Traceback (most recent call last): File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 226, 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 "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 313, in get_one_user self.write_user(self.user) File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 137, in write_user writer.write_user(user) File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\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 "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\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'

作者你好,爬取这个用户微薄(https://weibo.com/u/7166086720)时,会出现NoneType错误

爬取这个微博时https://weibo.com/u/5536604741,会出现这个错误:

list index out of range Traceback (most recent call last): File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 318, in get_one_user self.download_user_avatar(user_config['user_uri']) File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\spider.py", line 146, in download_user_avatar avatar_album_url = PhotoParser(self.cookie, File "C:\Users\丑的完美\AppData\Local\Programs\Python\Python39\lib\site-packages\weibo_spider\parser\photo_parser.py", line 15, in extract_avatar_album_url return "https://weibo.cn" + result[0] IndexError: list index out of range

choudewanmei commented 2 years ago

作者你好,我知道了,是我自己的那一个微博账号被ban了,被限制了。

我换了个账号,可以使用了,谢谢作者大大。

我的这两个问题好像都是因为自己账号被ban导致的,如有遇到跟我一样问题的朋友们,可以换个账号/cookie,谢谢作者大大