Failed to obtain weibo.cn cookie from Chrome browser 结果文件没有内容
为了更好的解决问题,请认真回答下面的问题。等到问题解决,请及时关闭本issue。
- 问:请您指明哪个版本运行出错(github版/PyPi版/全部)?
答:github
- 问:您使用的是否是最新的程序(是/否)?
答:是
- 问:爬取任意用户都会运行出错吗(是/否)?
答:否
试着爬取白敬亭的,也报了同样的错,但是结果正常(有数据) Failed to obtain weibo.cn cookie from Chrome browser: This operation requires admin. Please run as admin. Check for cookie failed: This operation requires admin. Please run as admin. Using the cookie field in config.json as the request cookie.
- 问:若只有爬特定微博时才出错,能否提供出错微博的weibo_id或url(非必填)?
答:用户id: 2311331195
- 问:若您已提供出错微博的weibo_id或url,可忽略此内容,否则能否提供出错账号的user_id及您配置的since_date,方便我们定位出错微博(非必填)?
答: "since_date": "2017-01-01", "end_date": "2019-01-01",
- 问:如果方便,请您描述出错详情,最好附上错误提示。
答:报错信息如下 (weiboSpider) E:\weiboSpider\weibo_spider>python main.py Failed to obtain weibo.cn cookie from Chrome browser: This operation requires admin. Please run as admin. Check for cookie failed: This operation requires admin. Please run as admin. Using the cookie field in config.json as the request cookie. 用户昵称: 深圳地铁 用户id: 2311331195 微博数: 48981 关注数: 177 粉丝数: 2757000
深圳地铁信息写入txt文件完毕,保存路径:E:\weiboSpider\weibo_spider\weibo\深圳地铁\2311331195.txt
Progress: 0%| | 0/272 [00:00<?, ?it/s]E:\weiboSpider\weibo_spider\parser\page_parser.py:47: FutureWarning: Truth-testing of elements was a source of confusion and will always return True in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. if self.selector: ------------------------------已获取深圳地铁(2311331195)的第1页微博------------------------------ Progress: 0%|▏ | 1/272 [00:01<05:27, 1.21s/it]------------------------------已获取深圳地铁(2311331195)的第2页微博------------------------------ Progress: 1%|▍ | 2/272 [00:02<05:16, 1.17s/it]------------------------------已获取深圳地铁(2311331195)的第3页微博------------------------------ Progress: 1%|▍ | 2/272 [00:03<07:46, 1.73s/it] 共爬取0条原创微博 信息抓取完毕
已按照下面链接获取Cookie,并验证了cookie的有效性 https://github.com/dataabc/weibo-crawler#%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96cookie%E5%8F%AF%E9%80%89
两个输出文件内容如下:
可能和end_date有关,它的值如果不是now,会漏爬微博。
深圳地铁微博主页在2024年12月25号之后才有数据,我尝试把end_date设为2024年12月24号,爬取不到数据,改为2024年12月31号后就有数据了。这是不是代表爬虫爬取不到微博主页没有的数据鸭/(ㄒoㄒ)/~~ 这种有解决办法吗
把end_date的值改成now就可以。
大佬 可以从指定起始页开始爬取数据吗 把end_date的值改成now后,爬取到一定页数就会报错 NoneType' object has no attribute 'xpath' Traceback (most recent call last): File "E:\weiboSpider\weibo_spider\parser\page_parser.py", line 66, in get_one_page info = self.selector.xpath("//div[@class='c']") AttributeError: 'NoneType' object has no attribute 'xpath' Progress: 10%|██████▉ | 28/281 [10:40<1:36:26, 22.87s/it] cannot unpack non-iterable NoneType object Traceback (most recent call last): File "E:\weiboSpider\weibo_spider\spider.py", line 180, in get_weibo_info weibos, self.weibo_id_list, to_continue = PageParser( TypeError: cannot unpack non-iterable NoneType object
不想每次都从头开始爬取,这种该怎么解决鸭
修改spider.py文件的get_weibo_info方法,大约在179行,range里的第一个数字就是开始页数。
大佬 我从第一页开始,不停改起始页,现在爬取了2985条微博数据,但是到第247页就没有数据了(时间倒回到2025-01-02),这种该怎么解决呀 我要的是2017-2018年的数据/(ㄒoㄒ)/~~
(weiboSpider) E:\weiboSpider\weibo_spider>python main.py Failed to obtain weibo.cn cookie from Chrome browser: This operation requires admin. Please run as admin. Check for cookie failed: This operation requires admin. Please run as admin. Using the cookie field in config.json as the request cookie. 用户昵称: 深圳地铁 用户id: 2311331195 微博数: 49096 关注数: 177 粉丝数: 2757000
深圳地铁信息写入txt文件完毕,保存路径:E:\weiboSpider\weibo_spider\weibo\深圳地铁\2311331195.txt
Progress: 0%| | 0/3 [00:00<?, ?it/s]E:\weiboSpider\weibo_spider\parser\page_parser.py:47: FutureWarning: Truth-testing of elements was a source of confusion and will always return True in future versions. Use specific 'len(elem)' or 'elem is not None' test instead. if self.selector: ------------------------------已获取深圳地铁(2311331195)的第247页微博------------------------------ Progress: 33%|████████████████████████▋ | 1/3 [00:21<00:43, 21.54s/it]------------------------------已获取深圳地铁(2311331195)的第248页微博------------------------------ Progress: 67%|█████████████████████████████████████████████████▎ | 2/3 [00:22<00:09, 9.58s/it]------------------------------已获取深圳地铁(2311331195)的第249页微博------------------------------ Progress: 67%|█████████████████████████████████████████████████▎ | 2/3 [00:23<00:11, 11.92s/it] 共爬取0条原创微博 信息抓取完毕
如果是微博限制,程序也没办法。