一、什么是小眼睛笔记访问量
如下图所示,为笔记访问量。
二、小眼睛笔记访问量接口
1、url
https://edith.xiaohongshu.com/api/sns/web/v1/note/metrics_report
2、payload
data={
"note_id": note_id,
"note_type": note_type,
"report_type": 1,
"stress_test": False,
"viewer": {
"user_id": viewer_id,
"followed_author": 0
},
"author": {
"user_id": user_id
},
"interaction": {
"like": 0,
"collect": 0,
"comment": 0,
"comment_read": 0
},
"note": {
"stay_seconds": 0
},
"other": {
"platform": "web"
}
}
参数说明:
note_id:要刷的笔记ID;
note_type:笔记类别;1为图文;2为视频;
viewer.user_id:访问笔记的使用者ID;
author.user_id:笔记作者的ID;
经测试发现,除了这四个字段,其它字段固定不变。
二、python刷流量源代码
# -*- coding: UTF-8 -*-
import time
import requests
import json
import random,math
import execjs
def brush(note_id,note_type,user_id):
a1,webId,viewer_id,web_session=register_session() #动态注册一个访问者身份及会话
data={
"note_id": note_id,
"note_type": note_type,
"report_type": 1,
"stress_test": False,
"viewer": {
"user_id": viewer_id,
"followed_author": 0
},
"author": {
"user_id": user_id
},
"interaction": {
"like": 0,
"collect": 0,
"comment": 0,
"comment_read": 0
},
"note": {
"stay_seconds": 0
},
"other": {
"platform": "web"
}
}
data_json=json.dumps(data,ensure_ascii=False, separators=(",", ":"))
headers={
"accept": "application/json, text/plain, */*",
"content-type": "application/json;charset=UTF-8",
"Referer": "https://www.xiaohongshu.com/",
"Sec-Ch-Ua": "\"Not_A Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Google Chrome\";v=\"115\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Windows\"",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"X-S-Common": "2UQAPsHC+aIjqArjwjHjNsQhPsHCH0rjNsQhPaHCH0P1+jhIHjIj2eHjwjQgynEDJ74AHjIj2ePjwjQhyoPTqBPT49pjHjIj2ecjw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PbZEp98QyaRSp9P98pSl4oSzcgmca/P78nTTL0bz/sVManD9q9z1J7+xJMcM2gbFnobl4MSUcdb6agW3tF4ryaRApdz3agWIq7YM47HFqgzkanTU4FSkN7+3G9PAaL+P8DDA/9LI4gzVP0mrnd+P+nprLFkSyS87PrSk8nphpd4PtMmFJ7Ql4BYcnLkSpfloNFS9zrzQyobL8M87/Fkl4opQ2rp0nS+N8p8M4eSQ4d8SpS8FnDS3JrTQyAYUJDr9qMSpqp8CNApSyS8F2fR/+g+/G7Qg2fcM8p+gGMmQ2o8SzbmFNFSbN9pf4gzBqSSnpLE1/r4Q2BRSpop7JBETP9ph8rpcanTg/FSkaBMlqAYraL+rqaTBpfRQyn+k8pmF+LSenfWFcDEAzomN8gYl4rbQPFbAyfq7qM40O/FjNsQhwaHCP0Z7+eq7+AHI+aIj2erIH0iAKc==",
"X-B3-Traceid": get_traceid(),
"Cookie": f"a1={a1};webId={webId};web_session={web_session}",
}
# 调用js签名文件。
with open('xs20230530.js', 'r', encoding='utf-8') as f:
js = f.read()
crt = execjs.compile(js)
xs_xt = crt.call('get_xs', '/api/sns/web/v1/note/metrics_report', data_json, a1) #x-s数据签名
xs_xt['X-t'] = str(xs_xt['X-t'])
headers["X-S"] = xs_xt["X-s"]
headers["X-T"] = xs_xt["X-t"]
url="https://edith.xiaohongshu.com/api/sns/web/v1/note/metrics_report"
res = requests.post(url, data=data_json.encode('utf-8'),headers=headers,proxies=proxies) #通过代理访问
print(res.text)
if __name__ == '__main__':
note_id = "649ce647000000001300c901" #要刷的笔记ID
note_type=2 #笔记类型为视频
user_id= "640d1628000000001400dc4d" #笔记作者
#brush(note_id,note_type,user_id)
i=1000 #刷1000次
while i>0:
brush(note_id,note_type,user_id)
time.sleep(random.randint(3,5)) #每次随机间隔3至5秒
i=i-1
print(i)
三、不断增加笔记访问量的方法(动态注册访问者身份及会话)
1、通过metrics_report这个接口发POST请求,每请求一次可使访问量加1,APP端同步更新。
实测发现,如果使用固定的viewer.user_id和web_session多次POST,大概10次左右,小眼睛访问量不会增加了。
原因是同一个访问者同一个会话刷访问量是有限的。因此必须动态生成viewer.user_id访问者和web_session会话。
构造不同的访问者和会话才能使小眼睛访问量不断增加!技术~~支持:复制:byc6352
2、动态生成不同的访问者身份及会话
register_session()返回四个参数:a1,webId,viewer_id,web_session
功能是注册一个访问者会话,返回viewer_id为访问者ID,web_session为会话标识。
a1,webId为cookie里需要的参数;
这样每次POST刷访问量都使用不同的访问者身份和会话,同时开代理动态改变IP,就能模拟出不同的访问者身份及会话,使流量增加。
四、metrics_report接口调用成功返回
{"msg":"成功","data":{"success":true},"code":0,"success":true}
(图2)metrics_report接口调用结果
标签:note,21,web,python,metrics,viewer,user,type,id From: https://blog.51cto.com/u_16113078/7173621