当前位置:网站首页>【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
文章小尾巴
文章写作、模板、文章小尾巴可参考:《写作“小心思”》
感谢你看到最后,最后再说两点~
①如果你持有不同的看法,欢迎你在文章下方进行留言、评论。
②如果对你有帮助,或者你认可的话,欢迎给个小点赞,支持一下~
我是南方者,一个热爱计算机更热爱祖国的南方人。
(文章内容仅供学习参考,如有侵权,非常抱歉,请立即联系作者删除。)
边栏推荐
- Laravel event & subscription
- For the sustainable development of software testing, we must learn to knock code?
- Test essential tool - postman practical tutorial
- org.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms)错误解决
- Analysis on user behavior loss of data exploration e-commerce platform
- 哪有什么未来可期,不过是打工人临死前最后的幻想罢了
- Matlab farthest point sampling (FPS improved version)
- Laravel+redis generates an order number - automatically increase from 1 on the same day
- PHP数组拼接MySQL的in语句
- Thinking about business and investment
猜你喜欢

How to maintain efficient collaboration in remote office and achieve stable growth of projects | community essay solicitation

(翻译)使用眉状文本提高标题点击率

PHP通过第三方插件爬取数据

【2022年】江西省研究生数学建模方案、代码

数据探索电商平台用户行为流失分析
![[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大](/img/fa/f9bad44147ba9af21183b7bd630e32.png)
[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大

3500 word summary: a complete set of skills that a qualified software testing engineer needs to master

求两个线段公共部分的长度

Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry

Batch import of Excel data in applet
随机推荐
Mathematical knowledge: 01 sequence satisfying conditions - find combinatorial number
[stack] 921 Minimum Add to Make Parentheses Valid
What are the preferential activities for stock account opening? In addition, is it safe to open a mobile account?
测试必备工具—Postman实战教程
opencv -- 笔记
Some essential differences
聚焦绿色低碳,数据中心散热进入“智能冷却”新时代
AS400 大厂面试
[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大
There is no future to be expected. It is just the last fantasy of a migrant worker before he dies
PHP数组拼接MySQL的in语句
数据探索电商平台用户行为流失分析
计算特殊奖金
Qt5 mvc: revealing the secrets of data visualization
【Proteus仿真】Arduino UNO +74C922键盘解码驱动4X4矩阵键盘
TypeError: can‘t convert cuda:0 device type tensor to numpy. Use Tensor. cpu() to copy the tensor to
哪有什么未来可期,不过是打工人临死前最后的幻想罢了
Log4j2 threadcontext log link tracking
小程序中实现excel数据的批量导入
修复表中的名字(首字符大写,其他小写)

