Python实现post请求小红书笔记详情数据接口

338 阅读2分钟

小红书是一个社交电商平台,用户可以在平台上分享和发现商品、旅行、美妆等各种生活笔记。小红书的笔记详情数据接口可以提供用户在笔记详情页展示的内容,包括笔记的标题、内容、点赞数、评论数、分享数等信息。

以下是一个可能的小红书笔记详情数据接口的示例:

smallredbook.item_get_video-获取小红书笔记详情数据接口返回值说明

1.请求方式:HTTP POST GET ;复制 Taobaoapi2014 获取 API SDK 文件

2.请求 URL:o0b.cn/opandy

3.请求参数:

请求参数:num_iid=649c46ab000000002702ad36

参数说明:num_iid:笔记 ID

4.请求示例:

# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "api-gw.xxx.cn/smallredbook/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)

5.返回结果 `

{
	"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"
}