当前位置:网站首页>【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
文章小尾巴
文章写作、模板、文章小尾巴可参考:《写作“小心思”》
感谢你看到最后,最后再说两点~
①如果你持有不同的看法,欢迎你在文章下方进行留言、评论。
②如果对你有帮助,或者你认可的话,欢迎给个小点赞,支持一下~
我是南方者,一个热爱计算机更热爱祖国的南方人。
(文章内容仅供学习参考,如有侵权,非常抱歉,请立即联系作者删除。)
边栏推荐
- (翻译)实时内联验证更容易让用户犯错的原因
- Relationship between ASCII, Unicode, GBK, UTF-8
- PHP crawls data through third-party plug-ins
- Try new possibilities
- What will Web3 bring in the future?
- After working for 6 years, let's take stock of the golden rule of the workplace where workers mix up
- 数据探索电商平台用户行为流失分析
- 【2022年】江西省研究生数学建模方案、代码
- Fast understanding of forward proxy and reverse proxy
- 求两个线段公共部分的长度
猜你喜欢
7-2 拼题A打卡奖励 dp
测试必备工具-Postman实战教程
Complete software development process
(翻译)使用眉状文本提高标题点击率
【2022年】江西省研究生数学建模方案、代码
求两个线段公共部分的长度
物业怎么发短信通知给业主?
45 year old programmer tells you: why do programmers want to change jobs? It's too true
Lecun, a Turing Award winner, pointed out that the future of AI lies in self-learning, and the company has embarked on the journey
Creating ASCII art with C #
随机推荐
Lecun, a Turing Award winner, pointed out that the future of AI lies in self-learning, and the company has embarked on the journey
MYSQL 数据库查看磁盘占用情况
Mathematical knowledge: 01 sequence satisfying conditions - find combinatorial number
laravel 事件 & 订阅
Composants de la grille de données portatifs
面对产业互联网的时候,甚至还用消费互联网的方式和方法去落地和实践产业互联网
New opportunities for vr/ar brought by metauniverse
electron之坑addon
Institute of Microbiology, commonly used biochemical reactions in microbiological testing
AS400 large factory interview
laravel+redis 生成订单号-当天从1开始自增
【多源bfs】934. Shortest Bridge
哪有什么未来可期,不过是打工人临死前最后的幻想罢了
Applet Custom Grid
(翻译)使用眉状文本提高标题点击率
Sort custom function
3500 word summary: a complete set of skills that a qualified software testing engineer needs to master
System settings large page
Complete software development process
KS009基于SSH实现宠物管理系统