Skip to content

Instantly share code, notes, and snippets.

@gongpeione
Last active April 4, 2024 07:51
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gongpeione/ba186882b8db4308ea1b0c540e91490d to your computer and use it in GitHub Desktop.
Save gongpeione/ba186882b8db4308ea1b0c540e91490d to your computer and use it in GitHub Desktop.
微博炸号找回部分内容
/**
* 1 打开 https://m.weibo.cn/beta 登陆你被炸的账号
* 2 打开浏览器控制台
**/
function delay (time) {
return new Promise(r => {
setTimeout(() => r(), time || 1000); // 延时 1s,可适当增加延长时间
});
}
const baseUrl = 'https://m.weibo.cn';
const tasks = {
atMe: `${baseUrl}/message/mentionsAt`,
atMeInCmt: `${baseUrl}/message/mentionsCmt`,
cmt: `${baseUrl}/message/cmt`,
};
async function runTask (taskUrl) {
const allRecord = [];
let end = false;
for (let page = 1; ; page++) {
try {
let d = await fetch(`${taskUrl}?page=${page}`, {credentials: "same-origin"})
.then(r => r.json())
.then(d => {
if (!d.data) {
end = true;
return;
}
const all = d.data.map(i => ({
created_at: i.created_at,
id: i.id,
statusId: i.status ? i.status.id : (i.retweeted_status ? i.retweeted_status.id : null),
source: i.source,
text: i.text,
userId: i.user.id,
userName: i.user.screen_name
})
);
allRecord.push(...all);
});
} catch (e) {
continue;
}
if (end) {
break;
}
await delay();
}
console.log(allRecord);
// console.log(JSON.stringify(allRecord)); // 如果需要直接输出去掉前面的 // 即可,注意记录过多可能会卡
};
// 不需要的在前面加上 //
(async function () {
await runTask(tasks.atMe); // 获取所有 at 你的微博
await runTask(tasks.atMeInCmt); // 获取所有评论里 at 你的微博
await runTask(tasks.cmt); // 获取评论,不全
})();
/**
* 1 打开 https://m.weibo.cn/p/index?containerid=231093_-_selffollowed 这是你关注的
* 2 滚动到最后直到所有关注列表都加载出来了,执行下面的脚本
* 3 打开 https://m.weibo.cn/p/index?containerid=231016_-_selffans 这是你的粉丝列表
* 4 滚动到最后直到所有粉丝列表都加载出来了,执行下面的脚本
**/
console.log(Array.from(document.querySelectorAll('.m-panel .m-text-box h3'), i=>i.innerText).join(','));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment