網(wǎng)站怎么做微信登錄四川網(wǎng)站制作
為了使用小紅書的API接口獲取筆記詳情,你需要遵循以下步驟:
-
注冊(cè)并登錄開放平臺(tái),創(chuàng)建一個(gè)應(yīng)用并獲取App Key和App Secret。
-
使用App Key和App Secret獲取訪問令牌(Access Token)。
-
使用訪問令牌(Access Token)調(diào)用API接口獲取筆記詳情。
以下是一個(gè)簡單的Python示例,展示了如何使用requests
庫調(diào)用小紅書API接口獲取筆記詳情:
# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 請(qǐng)求示例 url 默認(rèn)請(qǐng)求參數(shù)已經(jīng)做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接口響應(yīng)示例
{"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"
}