自动化在控制台中创建的命令 (DevTools)
Automate commands created in the console (DevTools)
我有这两个命令:
window.scrollTo(0, 5000);
document.querySelectorAll('.components-button.components-button-size-mini.components-button-type-primary.components-button-theme-dark.desktop.components-button-inline').forEach(btn => btn.click());
我通过 DevTools 控制台在此站点上使用它们:
https://booyah.live/users/13080294/followers
但是当我向下滚动并加载更多配置文件时,有时 Google Chrome 会完全崩溃。
我想知道是否有任何方法可以自动执行这些命令并且不需要打开原始网站以便浏览器不会崩溃。
命令的用途:
1 - 滚动到末尾以加载更多配置文件
2 - 单击可用配置文件的“关注”按钮
不要模拟滚动,你的内存会很快溢出。只需模拟请求即可。 .
示例代码:
var maxFolowNumber = 1000;
var userProfileID = 13080294;
var yourUserProfileID = ...; // Got on your profile url.
run = () => {
for (let i = 0; i < maxFolowNumber; i += 100)
fetch(`https://booyah.live/api/v3/users/${userProfileID}/followers?cursor=${i}&count=100`, {"method": "GET"})
.then(j => j.text())
.then(k => JSON.parse(k).follower_list.forEach(q =>
fetch(`https://booyah.live/api/v3/users/${yourUserProfileID}/followings`, {
"body": `{\"followee_uid\":${q.uid}}`,
"method": "POST",
})
));
}
run();
我有这两个命令:
window.scrollTo(0, 5000);
document.querySelectorAll('.components-button.components-button-size-mini.components-button-type-primary.components-button-theme-dark.desktop.components-button-inline').forEach(btn => btn.click());
我通过 DevTools 控制台在此站点上使用它们:
https://booyah.live/users/13080294/followers
但是当我向下滚动并加载更多配置文件时,有时 Google Chrome 会完全崩溃。
我想知道是否有任何方法可以自动执行这些命令并且不需要打开原始网站以便浏览器不会崩溃。
命令的用途:
1 - 滚动到末尾以加载更多配置文件
2 - 单击可用配置文件的“关注”按钮
不要模拟滚动,你的内存会很快溢出。只需模拟请求即可。
示例代码:
var maxFolowNumber = 1000;
var userProfileID = 13080294;
var yourUserProfileID = ...; // Got on your profile url.
run = () => {
for (let i = 0; i < maxFolowNumber; i += 100)
fetch(`https://booyah.live/api/v3/users/${userProfileID}/followers?cursor=${i}&count=100`, {"method": "GET"})
.then(j => j.text())
.then(k => JSON.parse(k).follower_list.forEach(q =>
fetch(`https://booyah.live/api/v3/users/${yourUserProfileID}/followings`, {
"body": `{\"followee_uid\":${q.uid}}`,
"method": "POST",
})
));
}
run();