当前位置:网站首页>【JS】【掘金】获取关注了里不在关注者里的人
【JS】【掘金】获取关注了里不在关注者里的人
2022-07-01 01:17:00 【南方者】
逻辑大抄来源:[JS真好玩] 掘金创作者必备: 监控每天是谁取关了你?
效果展示

操作流程
复制完整代码到浏览器的控制台进行输出即可。
(注:如果出现已经有命名,① 可以尝试修改方法名、变量名。② 清空一下浏览器的缓存)
准备工作(获取对应的aid、uuid、user_id)
如:看④的链接对应跟的参数
完整代码
Tip:有需要换成你对应的aid、uuid、user_id;不然就是获取请求我的啦~
// 你的aid
var aid = "2608";
// 你的uuid
var uuid = "7004672915649250827";
// 你的user_id
var user_id = "2840793779295133";
// 不能给掘金太大压力,我们定义个sleep函数,0.5秒请求一次就好
const sleep = async () => new Promise(resolve => setTimeout(resolve, 500));
// 获取所有新增粉丝,保存到followers。
const getFollowees = async () => {
const followers = {
};
console.log('开始读取你的粉丝啦');
for (let i = 0; i < 100; i++) {
const res = await fetch("https://api.juejin.cn/user_api/v1/follow/followees?aid=" + aid + "&uuid=" + uuid + "&user_id=" + user_id + "&cursor=" + i * 20 + "&limit=20", {
"headers": {
"content-type": "application/json",
},
"referrer": "https://juejin.cn/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
const data = await res.json();
const result = data.data.data;
result.forEach(fan => {
followers[fan.user_id] = fan.user_name;
});
// 如果该页数量少于20,说明是最后一页,结束循环
if (result.length < 20) break;
// 不能给掘金太大压力,我们1秒请求一次就好
await sleep();
}
console.log('读取完毕你的粉丝啦');
return followers;
}
// 获取所有新增粉丝,保存到followers。
const getFollowers = async () => {
const followers = {
};
console.log('开始读取你的粉丝啦');
for (let i = 0; i < 100; i++) {
const res = await fetch("https://api.juejin.cn/user_api/v1/follow/followers?aid=" + aid + "&uuid=" + uuid + "&user_id=" + user_id + "&cursor=" + i * 20 + "&limit=20", {
"headers": {
"content-type": "application/json",
},
"referrer": "https://juejin.cn/",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
const data = await res.json();
const result = data.data.data;
result.forEach(fan => {
followers[fan.user_id] = fan.user_name;
});
// 如果该页数量少于20,说明是最后一页,结束循环
if (result.length < 20) break;
// 不能给掘金太大压力,我们1秒请求一次就好
await sleep();
}
console.log('读取完毕你的粉丝啦');
return followers;
}
// 获取你的粉丝们
const followers = await getFollowers();
// 获取你的关注们
const followees = await getFollowees();
// 查看遍历你的关注是否在你的粉丝里
const checkFollowees = Object.keys(followees).filter(fan => !(fan in followers));
console.log(checkFollowees.map(id => followees[id]));
更多好玩的,可参考这位大佬哦~
今天只是大佬的搬运工!~
HullQin
文章小尾巴
文章写作、模板、文章小尾巴可参考:《写作“小心思”》
感谢你看到最后,最后再说两点~
①如果你持有不同的看法,欢迎你在文章下方进行留言、评论。
②如果对你有帮助,或者你认可的话,欢迎给个小点赞,支持一下~
我是南方者,一个热爱计算机更热爱祖国的南方人。
(文章内容仅供学习参考,如有侵权,非常抱歉,请立即联系作者删除。)
边栏推荐
- Log4j2 threadcontext log link tracking
- Strictmode analysis activity leakage -strictmode principle (3)
- 如何选择券商?另外,手机开户安全么?
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
- laravel Carbon 时间处理类使用
- PHP通过第三方插件爬取数据
- 删除重复的电子邮箱
- 数学知识:满足条件的01序列—求组合数
- php将二维数组元素转为键值对
- AS400 large factory interview
猜你喜欢

小程序云开发之--微信公众号文章采集篇

测试必备工具-Postman实战教程

农产品换房?“变相”购房补贴!

计算特殊奖金

微研所,微生物检验中常用的生化反应

The personal test is effective, and the JMeter desktop shortcut is quickly created

Ks009 implementation of pet management system based on SSH

思特奇加入openGauss开源社区,共同推动数据库产业生态发展

数学知识:求组合数 III—求组合数

The argument type 'function' can't be assigned to the parameter type 'void function()‘
随机推荐
Log logrus third party library usage
Some items of OCR
如何选择券商?另外,手机开户安全么?
[Qt5 basics] random number display
[stack] 921 Minimum Add to Make Parentheses Valid
6月第4周榜单丨飞瓜数据UP主成长排行榜(哔哩哔哩平台)发布!
如何学习和阅读代码
zabbix如何配置告警短信?(预警短信通知设置流程)
Microbiological health, why is food microbiological testing important
C # customize and dynamically switch cursor
Selenium classic interview question - multi window switching solution
Winodws 快速添加开机启动项
Mathematical knowledge: finding combinatorial number IV - finding combinatorial number
Matlab farthest point sampling (FPS improved version)
TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to
Draw some interesting figures with flutter's canvas
45 year old programmer tells you: why do programmers want to change jobs? It's too true
Analysis on user behavior loss of data exploration e-commerce platform
短视频平台开发,依靠DrawerLayout实现侧滑菜单效果
(翻译)实时内联验证更容易让用户犯错的原因

