dataabc / weiboSpider

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

爬取微博时只获取了前几页内容就自动停止了,提示'NoneType' object has no attribute 'xpath' #544

Open shiverwang76 opened 7 months ago

shiverwang76 commented 7 months ago

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

答:github版

答:是

答:不确定

答:不确定

答:

答:------------------------------已获取胡锡进(1989660417)的第14页微博------------------------------ 10条微博写入csv文件完毕,保存路径:E:\weiboSpider\weibo\胡锡进\1989660417.csv 10条微博写入txt文件完毕,保存路径:E:\weiboSpider\weibo\胡锡进\1989660417.txt Progress: 1%|▊ | 14/1245 [06:31<9:34:08, 27.98s/it] 'NoneType' object has no attribute 'xpath' Traceback (most recent call last): File "E:\weiboSpider\weibo_spider\spider.py", line 179, in get_weibo_info weibos, self.weibo_id_list, to_continue = PageParser( File "E:\weiboSpider\weibo_spider\parser\page_parser.py", line 47, in init info = self.selector.xpath("//div[@class='c']") AttributeError: 'NoneType' object has no attribute 'xpath' 共爬取127条原创微博 信息抓取完毕

dataabc commented 7 months ago

感谢反馈。可能是被暂时限制了,如果方便,过几天再运行看看。

SoChiChung commented 7 months ago
'NoneType' object has no attribute 'nickname'
Traceback (most recent call last):
  File "C:\Users\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\weibo_spider\spider.py", line 313, in get_one_user
    self.write_user(self.user)
  File "C:\Users\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\weibo_spider\spider.py", line 137, in write_user
    writer.write_user(user)
  File "C:\Users\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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\lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\weibo_spider\writer\txt_writer.py", line 29, in <listcomp>
    [v + ':' + str(self.user.__dict__[k]) for k, v in self.user_desc])
AttributeError: 'NoneType' object has no attribute '__dict__'

我从断点的日期开始爬后 报了这个错误 我也很疑惑

但是过一会我重新运行程序 又好了 可以是冷却时间不够

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.