小红书笔记监测:竞品新笔记、评论与达人表现的取数方案
监测小红书竞品,用 xhs_note_search 按关键词+时间排序抓新笔记,xhs_note_detail 拿正文与互动,xhs_note_comments 拉评论做口碑分析,再做 xhs_user_notes 追单个达人的更新。全部 ¥0.2/次,失败不计费。
要调哪几个接口
| 接口 | 单价 | 次数 | 小计 | 用途 |
|---|---|---|---|---|
xhs_note_search | ¥0.2 | ×2 | ¥0.4 | 按关键词 + 排序抓候选笔记(返回 note_id) |
xhs_note_detail | ¥0.2 | ×1 | ¥0.2 | 正文、图片、互动量 |
xhs_note_comments | ¥0.2 | ×3 | ¥0.6 | 一级评论(游标翻页) |
xhs_sub_comments | ¥0.2 | ×1 | ¥0.2 | 对高赞评论再拉二级回复 |
| 每 1 篇笔记(2 页搜索 + 1 详情 + 3 页评论 + 1 页二级评论,共 7 次调用) | ¥1.4 | 单次完整流程 | ||
| 300 篇笔记 | ¥420 | 300 × ¥1.4 | ||
完整代码骨架
直接可跑:把 TOKEN 换成你的 fw_ token。失败与空结果都会跳过,不产生费用。
import time, requests
TOKEN, API = "fw_xxx", "https://finewisdom.top/api"
def call(method, **kw):
r = requests.get(API, params={"token": TOKEN, "method": method, **kw}, timeout=60).json()
return r["data"] if r.get("status") == "success" else None
def paged(method, max_pages=3, **kw):
rows, cursor = [], None
for _ in range(max_pages):
q = dict(kw)
if cursor:
q["start"] = cursor # 小红书用游标,不是 page
d = call(method, **q)
if not d:
break
batch = d.get("comments") or d.get("list") or []
if not batch:
break
rows += batch
cursor = d.get("_next_offset") or d.get("cursor")
if not cursor:
break
time.sleep(1.1)
return rows
def monitor(keyword, note_id=None):
# 做「新笔记监测」时给 sort_type 传按时间排序(取值见接口参数页);默认是综合排序
notes = call("xhs_note_search", keyword=keyword, page=1)
out = []
for n in (notes.get("list") or notes.get("items") or [])[:300]:
nid = n.get("note_id")
detail = call("xhs_note_detail", note_id=nid)
out.append({"note_id": nid, "title": (detail or {}).get("title"),
"liked": (detail or {}).get("liked_count"),
"comments": paged("xhs_note_comments", max_pages=3, note_id=nid)})
time.sleep(1.1)
return out
几个必须知道的坑
xhs_note_search的sort_type/note_type/note_time是筛选条件,做「新笔记监测」要把sort_type设成按时间排序(默认是综合排序),否则你拿到的是最热的老笔记。- 评论翻页用
start游标(传上一页返回的游标),不要传page。 - 二级评论必须先有一级评论的
comment_id,只对高赞评论展开,不然调用量爆炸。
常见问题
能拿到历史笔记吗?
只能拿到平台当前可见的。小红书自身限制可翻页深度,需要长期趋势就每天增量落库。
怎么控制成本?
两步过滤:先用搜索结果的互动数筛掉低价值笔记,再只对 Top N 拉评论。300 篇全量约 2100 次调用,筛到 80 篇约 560 次。