ReaJason / xhs

基于小红书 Web 端进行的请求封装。https://reajason.github.io/xhs/
MIT License
1.03k stars 295 forks source link

'NoneType' object is not callable #30

Closed scriptway closed 1 year ago

scriptway commented 1 year ago

使用的是python3.9 一开始还以为是我cookie的问题,换了好几次cookie还是报错


from xhs import XhsClient

cookie="a1=1886132f6cav7mfdpcid2mnbahv45uuvea5z3lvji30000329042;webId=b360cce06e1bcad5e48dafb7b612265e;gid=yYYKyqJiYydqyYYKyqJiK01hS0hW6ifUS3fJ2V36ID0xhuq84277hq888qJj84J8ji8dW2S0;gid.sign=3gVA5Ji2C13wAa8svTrYyqcJDc8=;webBuild=2.11.5;acw_tc=0ab967f98018c20dd6b0745ee8a1596c3750bf84d2f8727a93f5c10315054162; web_session=040069b253793fdd9ccd5842a2364b86586515;galaxy_creator_session_id=S5mv0vWIWqrCX2GSJK9LFaudFrUkNq7TYW3b;galaxy.creator.beaker.session.id=1687620188771003075230;xsecappid=creator-creator;websectiga=2a3d3ea002e7d92b5c9743590ebd24010cf3710ff3af8029153751e41a6af4a3;sec_poison_id=f93e48b6-3162-4f6f-9984-5fcd908695cb"
xhs_client=XhsClient(cookie)
# xhs_client.get_home_feed(xhs.FeedType.RECOMMEND)
xhs_client.get_note_by_id("63db8819000000001a01ead1")
Traceback (most recent call last):
  File "/Users/cyc/Desktop/小红书素材/run.py", line 6, in <module>
    xhs_client.get_note_by_id("63db8819000000001a01ead1")
  File "/usr/local/lib/python3.9/site-packages/xhs/core.py", line 190, in get_note_by_id
    res = self.post(uri, data)
  File "/usr/local/lib/python3.9/site-packages/xhs/core.py", line 176, in post
    self._pre_headers(uri, data, is_creator=is_creator)
  File "/usr/local/lib/python3.9/site-packages/xhs/core.py", line 148, in _pre_headers
    self.sign(url, data, a1=self.cookie_dict.get("a1"),
TypeError: 'NoneType' object is not callable

辛苦回复一下 感谢🙏🏻

ReaJason commented 1 year ago

现在需要自定义 sign 函数来使用,请参考 快速入门,目前并没有实现签名,所以使用方式略微复杂