NanmiCoder / NanmiCoder/MediaCrawler

知乎爬虫 Request error: {"error":{"code":101,"name":"AuthenticationError","message":"ZERR_NOT_LOGIN"}}

Open
#517 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
65.3k
Forks
12.6k
PR merge metrics
No merged PRs in 30d

Description

对于这个错误尚不清楚如何解决,还大佬指导一下~

2024-12-09 09:11:10 MediaCrawler INFO (core.py:289) - [ZhihuCrawler.launch_browser] Begin create browser context ...                                                                                                                                                   
2024-12-09 09:11:12 MediaCrawler INFO (core.py:258) - [ZhihuCrawler.create_zhihu_client] Begin create zhihu API client ...                                                                                                                                             
2024-12-09 09:11:12 MediaCrawler INFO (client.py:136) - [ZhiHuClient.pong] Begin to pong zhihu...                                                                                                                                                                      
2024-12-09 09:11:12 MediaCrawler ERROR (client.py:90) - [ZhiHuClient.request] Requset Url: https://www.zhihu.com/api/v4/me?include=email%2Cis_active%2Cis_bind_phone, Request error: {"error":{"code":100,"name":"AuthenticationInvalidRequest","message":"请求头或参数
封装错误"}}                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
2024-12-09 09:11:13 MediaCrawler ERROR (client.py:90) - [ZhiHuClient.request] Requset Url: https://www.zhihu.com/api/v4/me?include=email%2Cis_active%2Cis_bind_phone, Request error: {"error":{"code":100,"name":"AuthenticationInvalidRequest","message":"请求头或参数
封装错误"}}                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
2024-12-09 09:11:15 MediaCrawler ERROR (client.py:90) - [ZhiHuClient.request] Requset Url: https://www.zhihu.com/api/v4/me?include=email%2Cis_active%2Cis_bind_phone, Request error: {"error":{"code":100,"name":"AuthenticationInvalidRequest","message":"请求头或参数
封装错误"}}                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
2024-12-09 09:11:15 MediaCrawler ERROR (client.py:146) - [ZhiHuClient.pong] Ping zhihu failed: RetryError[<Future at 0x7f9f24a9ad90 state=finished raised DataFetchError>], and try to login again...                                                                  
2024-12-09 09:11:15 MediaCrawler INFO (login.py:58) - [ZhiHu.begin] Begin login zhihu ...                                                                                                                                                                              
2024-12-09 09:11:15 MediaCrawler INFO (login.py:108) - [ZhiHu.login_by_cookies] Begin login zhihu by cookie ...                                                                                                                                                        
2024-12-09 09:11:15 MediaCrawler INFO (core.py:89) - [ZhihuCrawler.start] Zhihu跳转到搜索页面获取搜索页面的Cookies,该过程需要5秒左右                                                                                                                                  
2024-12-09 09:11:21 MediaCrawler INFO (core.py:111) - [ZhihuCrawler.search] Begin search zhihu keywords                                                                                                                                                                
2024-12-09 09:11:21 MediaCrawler INFO (core.py:118) - [ZhihuCrawler.search] Current search keyword: 汽车                                                                                                                                                               
2024-12-09 09:11:21 MediaCrawler INFO (core.py:127) - [ZhihuCrawler.search] search zhihu keyword: 汽车, page: 1                                                                                                                                                        
2024-12-09 09:11:22 MediaCrawler INFO (client.py:212) - [ZhiHuClient.get_note_by_keyword] Search result: {'paging': {'is_end': False, 'next': 'https://api.zhihu.com/search_v3?advert_count=0&correction=1&filter_fields=&gk_version=gz-gaokao&lc_idx=0&limit=20&offset
=20&q=%E6%B1%BD%E8%BD%A6&search_hash_id=6cd8c97771a7c7d75956db132dbae18d&search_source=Filter&show_all_topics=0&sort=&t=general&time_interval=&vertical=&vertical_info=0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C0%2C2%2C0'}, 'data': [{'type': 'search_result', 'highlight': {'d
······
stion_id': '562563592', 'title': '电动汽车为什么一下爆发了?', 'desc': '人类早就有能力造电动车了啊,是什么契机,技术进步这两年爆发的?', 'created_time': 1709466282, 'updated_time': 1710330624, 'voteup_count': 15420, 'comment_count': 2457, 'source_keyword': '汽车', 'user_id': '51c6b8c755f776354a3e966e881bbbda', 'user_link': 'https://www.zhihu.com/people/di-ren-jie-57', 'user_nickname': '狄仁杰', 'user_avatar': 'https://pic1.zhimg.com/50/v2-2df28424e6e8e451a5454c091bf6c0ae_l.jpg?source=4e949a73', 'user_url_token': 'di-ren-jie-57', 'last_modify_ts': 1733735482784}
2024-12-09 09:11:22 MediaCrawler INFO (core.py:168) - [ZhihuCrawler.batch_get_content_comments] Crawling comment mode is not enabled
2024-12-09 09:11:22 MediaCrawler INFO (core.py:127) - [ZhihuCrawler.search] search zhihu keyword: 汽车, page: 2
2024-12-09 09:11:23 MediaCrawler ERROR (client.py:90) - [ZhiHuClient.request] Requset Url: https://www.zhihu.com/api/v4/search_v3?gk_version=gz-gaokao&t=general&q=%E6%B1%BD%E8%BD%A6&correction=1&offset=20&limit=20&filter_fields=&lc_idx=20&show_all_topics=0&search_source=Filter&time_interval=&sort=&vertical=, Request error: {"error":{"code":101,"name":"AuthenticationError","message":"ZERR_NOT_LOGIN"}}

2024-12-09 09:11:24 MediaCrawler ERROR (client.py:90) - [ZhiHuClient.request] Requset Url: https://www.zhihu.com/api/v4/search_v3?gk_version=gz-gaokao&t=general&q=%E6%B1%BD%E8%BD%A6&correction=1&offset=20&limit=20&filter_fields=&lc_idx=20&show_all_topics=0&search_source=Filter&time_interval=&sort=&vertical=, Request error: {"error":{"code":101,"name":"AuthenticationError","message":"ZERR_NOT_LOGIN"}}

2024-12-09 09:11:25 MediaCrawler ERROR (client.py:90) - [ZhiHuClient.request] Requset Url: https://www.zhihu.com/api/v4/search_v3?gk_version=gz-gaokao&t=general&q=%E6%B1%BD%E8%BD%A6&correction=1&offset=20&limit=20&filter_fields=&lc_idx=20&show_all_topics=0&search_source=Filter&time_interval=&sort=&vertical=, Request error: {"error":{"code":101,"name":"AuthenticationError","message":"ZERR_NOT_LOGIN"}}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with client.py around ZhiHuClient.request and pong, then inspect login.py and core.py where cookie login and search are invoked. Reproduce the authentication failure with the shown search request and trace how cookies and request headers are created. Done means the affected Zhihu flow no longer produces the reported authentication error, with regression coverage for the failing path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.