网站怎么做微信登录seo扣费系统
为了使用小红书的API接口获取笔记详情,你需要遵循以下步骤:
-
注册并登录开放平台,创建一个应用并获取App Key和App Secret。
-
使用App Key和App Secret获取访问令牌(Access Token)。
-
使用访问令牌(Access Token)调用API接口获取笔记详情。
以下是一个简单的Python示例,展示了如何使用requests
库调用小红书API接口获取笔记详情:
# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://item_get_video/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=649c46ab000000002702ad36"
headers = {"Accept-Encoding": "gzip","Connection": "close"
}
if __name__ == "__main__":r = requests.get(url, headers=headers)json_obj = r.json()print(json_obj)
API接口响应示例
{"item": {"num_iid": "649c46ab000000002702ad36","detail_url": "https://www.xiaohongshu.com/explore/649c46ab000000002702ad36","title": "变形金刚4","type": "video","video": "http://sns-video-qc.xhscdn.com/stream/110/258/01e49c46a63bcd390103770389027d1ad7_258.mp4?sign=180a24669a446bf75a3ec79f41926bcb&t=64a04c54","pic_url": "https://sns-img-hw.xhscdn.com/0ccd59b9-71ad-d2c0-ec5a-afac90d21355?imageView2/2/h/1920/format/webp|imageMogr2/strip","tag_list": [{"name": "变形金刚","type": "topic","id": "545c2716d6e4a924bf74ed49"}],"desc": " 这就是柱子哥的魅力","city": "河北","nick": "变形金刚电影剪辑","uid": "64805fc1000000000f004891","interact_info": {"liked_count": "41","collected_count": "16","comment_count": "0"},"time": "2023-06-28 22:41:47","_ddf": "mt"},"error": "","reason": "","error_code": "0000","cache": 0,"api_info": "today:182 max:10100 all[5611=182+44+5385];expires:2030-12-31","execution_time": "1.957","server_time": "Beijing/2023-06-30 17:21:49","client_ip": "106.6.34.137","call_args": [],"api_type": "smallredbook","translate_language": "zh-CN","translate_engine": "baidu","server_memory": "3.03MB","request_id": "1.649e9eab4b441","last_id": "1840805874"
}