2024年nodejs调用小红书最新关注(粉丝)follow接口,api接口分析2004-04-16


一、打开chrome按f12,点击右上角的“关注”按钮,抓包位置如下:


(图1 follow接口)


二、follow接口分析


1、请求地址

https://edith.xiaohongshu.com/api/sns/web/v1/user/follow

2、请求方法:
POST
3、请求头:


:authority:
edith.xiaohongshu.com
:method:
POST
:path:
/api/sns/web/v1/user/follow
:scheme:
https
Accept:
application/json, text/plain, */*
Accept-Encoding:
gzip, deflate, br, zstd
Accept-Language:
zh-CN,zh;q=0.9
Content-Length:
45
Content-Type:
application/json;charset=UTF-8
Cookie:
{.........此处省略..............}
Origin:
https://www.xiaohongshu.com
Referer:
https://www.xiaohongshu.com/
Sec-Ch-Ua:
"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"
Sec-Ch-Ua-Mobile:
?0
Sec-Ch-Ua-Platform:
"Windows"
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
same-site
User-Agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
X-B3-Traceid:
c47c9349e64fd39d
X-S:
XYW_eyJzaWduU3ZuIjoiNTEiLCJzaWduVHlwZSI6IngxIiwiYXBwSWQiOiJ4aHMtcGMtd2ViIiwic2lnblZlcnNpb24iOiIxIiwicGF5bG9hZCI6IjQwMGQwNzU2NmQ2MjE0MjU0NTZkY2RkNTZlOGRlMjU4ZTVmOWZjOGQxODU5ZDllODk2MjMxMzA2OGY1NmU0MjQ3NTQ2NGJjNzNlNmU1ZWMyZjg4NTJhNzdhYzcxMTNkYWM5ZTNiZmRhMWZhYTFlYjkwZDc0YWEzMWI1NGM3MmNkMGQ3NGFhMzFiNTRjNzJjZGFjNDg5YjlkYThjZTVlNDhmNGFmYjlhY2ZjM2VhMjZmZTBiMjY2YTZiNGNjM2NiNTUzZjAxZTk0Nzg2NWIwZGE5MzU0MGFkNzFmODhhNmViNDRlYmQyOGZ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g+nqSQsaLptqM8f/9LAqgzPJdp7qLS94fpfpdzVaLL9qAP7zg+Q40pA+fP98/mc4FbQcFkSPgbF4DkS+obQyrD3a/PMqA8U8Bp3JDkS8oHIqM+n4ozQypmaa/+84nRc4BbQcMbnaLpSqA+PzBYFpLEA8dbFqLSi/oQyLozaPfPAqMSIcnpgLo4TJMm74FS9nSYQypmFGMm7Ggbc47pQ2rkA8bkt8/bM4FEIqgz9aLp32nQc4b4QP7QC8FQawrS3Po+88rEA8fEw8pzn47zF4gzHaLLFqDS98Bph4g4aanSSqAmQp0SQ2op7Gp+n/FSeqnRQcFESyMm78okl4rkzLocha/+MzLSiPo+h8/mSygbFLMkyLDpQPF4czM8FqnMn4eYQPF4na/P3GDSbqgpQy9pApSSS8nTgn0bEpdzUa/+jP9Qn4bbSpdzLanYS8/8sqS+QyLqMz9Rd8n8l4rpyLoz1JL8LJf4AqBTQynTBNM87/DSk+gPlGAYoanTBJgkc4BkQyb8cwob78sRM49EQypQmagYUprDAtAQPLo4kanTc2DSbPoPApd43/M4VcFSi/bkQc94A8eZI8/bl4BkQ2b83anYinrl8p78QcAz8/BMzyrSh4fpfGFbAzbmFaDSkP9pLqg4OanVF4rDAa9p8LozsaL+T+gmc4McjNsQhwaHCP/ZFP0HE+APIPUIj2erIH0ilPALAKc==
X-T:
1713252619968

4、请求数据体

{"target_user_id":"59391d446a6a6960704f16b1"}

5、请求成功返回:

{"code":0,"success":true,"msg":"成功","data":{"fstatus":"follows"}}

三、nodejs调用接口代码


const https = require('node:https');
const fs = require("fs");
const os = require("os");
//----------------------------------------------调用模块初始化----------------------------------------------------
const m_common_data = require('./x_s_common.js');//X-S-Common签名
const m_xs_data = require('./xs.js');//X-S签名
const m_proxy = require('./proxy.js');
const agent=m_proxy.get_agent();
//mode by byc6352 or metabycf in 2024-01-05
exports.set_follow=set_follow;//target_user_id=被关注用户id    a1=从cookie提取的         web_session=从cookie提取的
async function set_follow(target_user_id,web_session,a1){let cookie=`abRequestId=b5675107-257c-5e9e-9bfe-157d0dc56027; webBuild=3.11.3; xsecappid=xhs-pc-web;a1=${a1};webId=4f4e47c26fec73469f2a0a1b36b59b49;web_session=${web_session}; websectiga=6169c1e84f393779a5f7de7303038f3b47a78e47be716e7bec57ccce17d45f99; sec_poison_id=30196e44-925f-4243-86da-685cafcc09e5;gid=yYDq8j0dy2M8yYDq8j0fW003JWv0DIMSFAY0kJMTIACS3928S0hi80888qKj8WW8DJyfKWW`;let url="https://edith.xiaohongshu.com/api/sns/web/v1/user/follow";let path=url.replace("https://edith.xiaohongshu.com","");let data={target_user_id: target_user_id};let data_str=JSON.stringify(data);let o=await m_xs_data.get_xs(path,data_str,a1);var xs=o["X-s"];var xt=o["X-t"];let x_common=m_common_data.get_common(a1,xt,xs);let traceid=m_common_data.get_traceid();let headers={"Connection":"close","authority":'edith.xiaohongshu.com',"method":'POST',"path":'/api/sns/web/v1/user/follow',"scheme":'https',"Accept":'application/json, text/plain, */*',//"Accept-Encoding":'gzip, deflate, br',"Accept-Language":'zh-CN,zh;q=0.9',"Content-Length":'45',"Content-Type":'application/json;charset=UTF-8',"Cookie":cookie,//"Origin":'https://www.xiaohongshu.com',"Referer":'https://www.xiaohongshu.com/',"Sec-Ch-Ua":'"Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"',"Sec-Ch-Ua-Mobile":'?0',"Sec-Ch-Ua-Platform":'"Windows"',"Sec-Fetch-Dest":'empty',"Sec-Fetch-Mode":'cors',"Sec-Fetch-Site":'same-site',"User-Agent":'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',"X-B3-Traceid":traceid,//'0a781c1de7825c27',"X-S":xs,//'XYW_eyJzaWduU3ZuIjoiNTEiLCJzaWduVHlwZSI6IngxIiwiYXBwSWQiOiJ4aHMtcGMtd2ViIiwic2lnblZlcnNpb24iOiIxIiwicGF5bG9hZCI6ImMwNjkwZjhiMmJjNWJlYzZjOD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FM/nMb2rFU//pyprEknfMayrMgnfY8pr8Vnnk34MkrGAm8pFpC/p4QPLEo//++JLE3/L4zPFEozfY+2D8k/SzayDECafkyzF8x/Dzd+pSxJBT8pBYxnSznJrEryBMwzF8TnnkVybDUnfk+PS8i/nkyJpkLcfS+ySDUnpzyyLEo/fk+PDEk/Szp2pSxzfTypFFF/pz32SSCLg4wyDM7/FziJrhUzg4ypr8infk02LMoz/mwPS8inD4+2rECL/QyzrrA/p4QPFMTng482DQT/dk3PrFUp/+8yDbE/gkpPrEgp/z+pr8xnDzzPFEonfTyzFMh/Fzz+LMLp/QwyDrMnSztJpSga/p82SkVnfkQPLRrGAQyzrET/D48+LMxyAmwpMki/F4b2rMga/bwpFLAngk3PpSgzgS+pMQTnfkwyLMx87YOpBYTnSzaJpDU/flyzrpEnS4z2bSga/Q8pFMEnSz34FhU/fk+zrFF/fks',"X-T":xt//'1709452415373',}const options = {hostname: 'edith.xiaohongshu.com',port: 443,path: path,method: 'POST',headers: headers}if(agent!==undefined)options.agent = agent;let req = https.request(url,options, (res) => {console.log(`STATUS: ${res.statusCode}`);console.log(`HEADERS: ${JSON.stringify(res.headers)}`);res.setEncoding('utf8');var body="";res.on('data', (chunk) => {body=body+chunk;});res.on('end', () => {try {console.log(body);}catch (e){console.error(e);}});res.on('close', () => {console.log("close");});});req.on('error', (e) => {console.error(`problem with request: ${e.message}`);});req.write(data_str,'utf8');req.end();}

第三方调用接口:

http://helpnow.top:8087/xhs/follow?key=234181402307&target_user_id=被关注用户id&a1=从cookie提取的&web_session=从cookie提取的

四、follow接口调用成功


(图2follow接口调用成功)

6Zeu6aKY5ZKo6K+i77yadng6YnljNjM1MiBvciBtZXRhYnljZjtRUTozOTg0ODg3Mjt0ZWxlZ3JhbTpieWMwMQ==(base64解码)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/623894.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Web3.0与AI的交融:开启智能互联网新时代

目前有140 多个 Web3 AI 概念项目,覆盖了基础设施、数据、预测市场、计算与算力、教育、DeFi & 跨链、安全、NFT & 游戏 & 元宇宙、搜索引擎、社交 & 创作者经济、AI 聊天机器人、DID & 消息传递、治理、医疗、交易机器人等诸多方向。持续关注…

MongoDB的go SDK使用集锦

在上一章解读MongoDB官方文档获取mongo7.0版本的安装步骤与基本使用介绍了如何使用mongo shell操作mongo数据库,接下来介绍如何使用sdk来操作数据库,这里以go语言为例,其他语言请查看源文档mongo docs Quick Start 内置数据结构 MongoDB是存…

关于idea中mybatis插件,下载后,无法生成代码模板--解决方法

一、不用相信网上其他解决方法 1.1试过,无效 二、解决方法 2.1【注:多试几次】重新下载,并重新启动idea 三、操作方法 3.1步骤 3.2idea重启,【如果没有重启】手动重启,必须有,很重要 3.3重新下载mybat…

电商技术揭秘九:搜索引擎中的SEO数据分析与效果评估

相关系列文章 电商技术揭秘一:电商架构设计与核心技术 电商技术揭秘二:电商平台推荐系统的实现与优化 电商技术揭秘三:电商平台的支付与结算系统 电商技术揭秘四:电商平台的物流管理系统 电商技术揭秘五:电商平台的个性…

【触想智能】如何选购到一款合适的工业电脑一体机

工业电脑一体机是专为工业环境而设计的一种工业计算机。工业电脑一体机和普通的计算机不一样,它对产品的参数性能要求很高,因为它们通常会运行在高低温、电磁干扰、高粉尘、湿度大的恶劣环境中,所以相应的要求工业电脑一体机必须具备良好的宽…

47.HarmonyOS鸿蒙系统 App(ArkUI)创建轮播效果

创建轮播效果,共3页切换 Entry Component struct Index {State message: string Hello Worldprivate swiperController: SwiperController new SwiperController()build() {Swiper(this.swiperController) {Text("第一页").width(90%).height(100%).bac…

记第一次踩坑Gradle

今天有个项目只能使用Gradle编译,没办法了,尝试吧。 先去下载了最新版本的Gradle,然后配置好了环境变量,可以在命令行使用gradle命令了。 然后打开项目开始操作一番,但是上来就傻眼了。 我白下载了,又重新下…

【火猫TV】NBA:赛季数据王总结,国王双雄爆冷入选

NBA常规赛已经全部结束,各项数据王诞生,我们发现不少新人球星开始挑大梁,他们用出色的发挥证明了自己的实力。下面,为大家简单盘点下各项数据的最佳球员! 得分王:东契奇(场均33.9分) 本赛季独行侠低开高走,东契奇保持了出色发挥,他场均贡献33.9分,比第二的字母哥场均多出3.5分…

STM32H7的8个串口fifo收发(兼容232和485)

STM32H7的8个串口fifo收发(兼容232和485) 串口硬件串口时序串口高级特性同步和异步的区别单工、半双工、全双工的区别 STM32H78个串口fifo驱动定义数据结构uart_fifo.huart驱动包括中断配置等 应用示例RS485深入理解 仅供学习。 USART 的全称是 Universa…

OSPF---综合实验

1、R4为ISP,其上只配置IP地址;R4与其他所直连设备间均使用公有IP; 2、R3-R5、R6、R7为MGRE环境,R3为中心站点; 3、整个OSPF环境IP基于172.16.0.0/16划分;除了R12有两个环回,其他路由器均有一个环…

水牛社:打造你的居家副业利器,让赚钱变得更简单

水牛社,这个已经陪伴我们走过九个春秋的综合性网络任务和项目资源整合平台,真的给我留下了深刻的印象。它不仅仅是一个资源的汇聚地,更是一个帮助无数人实现网络副业梦想的平台。作为一个资深用户,我深感其中的价值和魅力。 水牛…

vs2008使用 openmp

目录 1 在项目中找到property pages>>c/c>>language>>openmp支持 2 在环境变量中增加“OMP_NUM_THREADS”变量,数值自己根据你的CPU的性能来设置,一般2、4、8等 3 在项目中输入如下代码,并编译运行 4 结果与不使用omp的…