Comments (5)
from xhs.
我也想知道
from xhs.
不好意思各位,可以使用 git pip 一下最新的。
python -m pip install git+https://github.com/ReaJason/xhs
这个是 cookie 的 key 没做 trim 去除空格导致的,或者可以自行将分号和字母前的空格删除如
a1=xxx; web_session=xxx;
改为
a1=xxx;web_session=xxx;
from xhs.
正缺设置 cookie 后(登陆小红书,在浏览器中获取 cookie)。请求还是报错,trace如下。debug 了一下发现服务端返回的 http 状态码是 406,请问这是什么原因呢。
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/hongye/workspace/ppd/xhs-demo/main.py", line 49, in
notes = xhs_client.get_note_by_keyword("小红书")
File "/Users/hongye/workspace/ppd/xhs-demo/venv/lib/python3.9/site-packages/xhs/core.py", line 367, in get_note_by_keyword
return self.post(uri, data)
File "/Users/hongye/workspace/ppd/xhs-demo/venv/lib/python3.9/site-packages/xhs/core.py", line 176, in post
return self.request(method="POST", url=f"{self._host}{uri}",
File "/Users/hongye/workspace/ppd/xhs-demo/venv/lib/python3.9/site-packages/xhs/core.py", line 163, in request
raise DataFetchError(data.get("msg", None))
xhs.exception.DataFetchError: None
from xhs.
正缺设置 cookie 后(登陆小红书,在浏览器中获取 cookie)。请求还是报错,trace如下。debug 了一下发现服务端返回的 http 状态码是 406,请问这是什么原因呢。
Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/hongye/workspace/ppd/xhs-demo/main.py", line 49, in notes = xhs_client.get_note_by_keyword("小红书") File "/Users/hongye/workspace/ppd/xhs-demo/venv/lib/python3.9/site-packages/xhs/core.py", line 367, in get_note_by_keyword return self.post(uri, data) File "/Users/hongye/workspace/ppd/xhs-demo/venv/lib/python3.9/site-packages/xhs/core.py", line 176, in post return self.request(method="POST", url=f"{self._host}{uri}", File "/Users/hongye/workspace/ppd/xhs-demo/venv/lib/python3.9/site-packages/xhs/core.py", line 163, in request raise DataFetchError(data.get("msg", None)) xhs.exception.DataFetchError: None
不太清楚为什么会请求出错,本地测试是好着的。
![image](https://private-user-images.githubusercontent.com/48389642/249917149-60cab8ed-1f24-49ed-b14b-b0bec7cd7846.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDkyODE5ODcsIm5iZiI6MTcwOTI4MTY4NywicGF0aCI6Ii80ODM4OTY0Mi8yNDk5MTcxNDktNjBjYWI4ZWQtMWYyNC00OWVkLWIxNGItYjBiZWM3Y2Q3ODQ2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAzMDElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMzAxVDA4MjgwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU5MTIyMTQ5NDMzYWE3MzRiYzVhNDY0Mzk5NjU2YzY0OWFkZmQ0MTg3Zjc3YTNkYjBjMDI0MjdjZTRiNTNjZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.eRAgshsocsl9KsGv40VhkjeqUZpoeFAsPCtg1Av67EE)
我在代码中添加了,raise response,如果还出现你这个报错会打印响应内容
Line 165 in b02b87f
麻烦更新一下再试试,
python -m pip install git+https://github.com/ReaJason/xhs
,谢谢反馈💐嗷对了,小红书对代理敏感,尽量不要开代理使用
from xhs.
Related Issues (20)
- 发布接口报错:无登录信息 HOT 9
- 在文章中@别人,别人收不到信息,但是评论里能点开别人的信息 HOT 1
- 发布笔记接口,topics好像无效 HOT 4
- 请问有 私信接口吗 HOT 1
- 签名函数不一定能 work
- 关注用户,用户好像不能收到通知 HOT 1
- 如何监控被用户评论区@的消息 HOT 8
- feat: 将`xhs`封装为tools供ChatGPT调用
- 好像login_qrcode的二维码扫不出 HOT 1
- 浏览器打开后部分接口报406 HOT 1
- 请问有获取粉丝id的接口吗?想做一个批量取关的功能 HOT 2
- 测试方法test_create_note_with_ats_topics中at他人时的name与nickname是一样的吗? HOT 2
- 现在请求两三次就抓不到数据了,怎么办 HOT 2
- 下载笔记时,图片下载失败 HOT 3
- get_user_info get_user_notes get_note_by_id 这几个貌似失效了 HOT 1
- 图文话题 上传失败 HOT 3
- 关于代理和sign HOT 1
- 用手机验证码登录,执行login_phone.py报错,请问是什么原因 HOT 1
- 请问有增加“获取创作中心笔记列表”接口的计划吗? HOT 6
- 扫码登录时遇到httpcode 471 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xhs.