ReaJason / xhs

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

请求发布图片笔记接口报406 #103

Closed onemore118 closed 3 months ago

onemore118 commented 3 months ago

xhs version: 0.2.11 url:https://edith.xiaohongshu.com/web_api/sns/v2/note cookie: 使用了https://creator.xiaohongshu.com获取的cookie

def sign(uri, data=None, a1="", web_session=""):
    # 填写自己的 flask 签名服务端口地址
    res = requests.post("http://localhost:5005/sign",
                        json={"uri": uri, "data": data, "a1": a1, "web_session": web_session})
    signs = res.json()
    return {
        "x-s": signs["x-s"],
        "x-t": signs["x-t"]
    }

if __name__ == '__main__':
    cookie = "<获取的cookie>"
     xhs_client = XhsClient(cookie, sign=sign)
      # get note info
     title = "我是标题"
     desc = "一条笔记"
     images = [
          "/Desktop/1.png",
      ]
     note = xhs_client.create_image_note(title, desc, images, is_private=True)

另外调用获取笔记的接口也是报了406,使用curl是可用直接调用成功的,自己挂了代理也还是没有调用成功,请问是否是接口改动了。

onemore118 commented 3 months ago

可以了,是我的a1设置有问题,没有看到打印的提示。