Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

知乎更新,60s 接口返回的文本错乱【2】 #9

Open
Li1Fan opened this issue Jun 20, 2024 · 10 comments
Open

知乎更新,60s 接口返回的文本错乱【2】 #9

Li1Fan opened this issue Jun 20, 2024 · 10 comments

Comments

@Li1Fan
Copy link

Li1Fan commented Jun 20, 2024

          > ```python

url = 'https://www.zhihu.com/api/v4/columns/c_1715391799055720448/items'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
res = requests.get(url, headers=headers)
print(res.text)


这么直接请求倒是正常的
image

确实能正常拿到,但貌似现在这个问题官方不存在了...

现在数据一切正常,API 可正常使用。

Originally posted by @vikiboss in #8 (comment)

@Li1Fan
Copy link
Author

Li1Fan commented Jun 20, 2024

没有解决,有时候出现,有时候不出现

@vikiboss
Copy link
Owner

vikiboss commented Jun 20, 2024

没有解决,有时候出现,有时候不出现

浏览器无痕模式直接访问,也会带上 UA 的,但是之前无痕模式访问也会出现数据错乱的情况。

根据你的代码,你的意思,是用低版本的 UA 能够稳定拿到正常的数据?

@vikiboss
Copy link
Owner

我没有空频繁去 debug 和找解决方案,如果你觉得你的方案可以完美解决,欢迎 PR

@vikiboss vikiboss changed the title 60s接口返回值文本错乱 知乎更新,60s 接口返回的文本错乱【2】 Jun 20, 2024
@vikiboss
Copy link
Owner

https://github.com/DIYgod/RSSHub/blob/master/lib/routes/zhihu/utils.ts#L58-L103

知乎加了东西,这有解决方案,要加一个请求头 cookie,有时间再搞。

@vikiboss
Copy link
Owner

先用环境变量临时处理一下,这个 Cookie 貌似一周有效,我记起来就更下,闲了再细搞。

https://github.com/vikiboss/60s/blob/main/src/services/60s.ts#L22

https://github.com/vikiboss/60s/blob/main/src/services/60s.ts#L32

@Li1Fan
Copy link
Author

Li1Fan commented Jun 21, 2024

我试了把header都加上,稳定了很多
{
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "zh-CN,zh;q=0.9",
"sec-ch-ua": ""Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"",
"sec-ch-ua-mobile": "?1",
"sec-ch-ua-platform": ""Android"",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Mobile Safari/537.36"
}

@lie-jiu
Copy link

lie-jiu commented Aug 2, 2024

QQ_1722573336819

@vikiboss
Copy link
Owner

vikiboss commented Aug 2, 2024

QQ_1722573336819

现在应该好了

@lie-jiu
Copy link

lie-jiu commented Aug 2, 2024

QQ_1722573336819

现在应该好了

QQ_1722573336819

现在应该好了

我拿来写微信脚本的
文本错乱我就获取链接
跳转知乎了

@vikiboss
Copy link
Owner

vikiboss commented Aug 2, 2024

@lie-jiu 这个降级处理可以的。

主要是知乎新加的 Cookie 鉴权,目前没时间跟进,只能定时更新后台的 Cookie 环境变量。

如果需要及时处理的话,欢迎加入 readme 的反馈群聊,看到及时更新。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants