Git Product home page Git Product logo

Comments (5)

ranyong1997 avatar ranyong1997 commented on July 30, 2024

我也尝试用web_session 也报错了
image

from xhs.

Esword618 avatar Esword618 commented on July 30, 2024

我也想知道

from xhs.

ReaJason avatar ReaJason commented on July 30, 2024

不好意思各位,可以使用 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.

huyhi avatar huyhi commented on July 30, 2024

正缺设置 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.

ReaJason avatar ReaJason commented on July 30, 2024

正缺设置 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

我在代码中添加了,raise response,如果还出现你这个报错会打印响应内容

xhs/xhs/core.py

Line 165 in b02b87f

raise DataFetchError(data.get("msg", data))

麻烦更新一下再试试,python -m pip install git+https://github.com/ReaJason/xhs,谢谢反馈💐
嗷对了,小红书对代理敏感,尽量不要开代理使用

from xhs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.