0

I have these two commands:

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());

I use them on this site via DevTools Console:
https://booyah.live/users/13080294/followers

But as I scroll down and load more profiles, there comes a time when Google Chrome crashes completely.

I would like to know if there is any way to automate these commands and that do not need to have the original website open so that the browser does not crash.

Purpose of the commands:

1 - Scroll to the end to load more profiles
2 - Click on the "follow" button of the available profiles

halfer
  • 19,824
  • 17
  • 99
  • 186
Digital Farmer
  • 1,705
  • 5
  • 17
  • 67
  • 1
    Use Puppeteer or a similar tool e.g. any CDP library for python to connect to a running Chrome instance. – wOxxOm Sep 15 '20 at 04:42

1 Answers1

1

Don't simulate scroll, you will be overflow your memory very quickly. Just simulate the request instead. See more.

Example code:

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();
namgold
  • 1,009
  • 1
  • 11
  • 32
  • Hi mate... It worked perfectly, but I realized that when trying to increase the number of profiles from 1000 to something like 250000, in a moment DevTools ends up crashing. And if I try to make several out of 1000, it doesn't work because it will continue to analyze only the first 1000 profiles that appear, so you won't find any more, right? Is there any option that solves this issue? – Digital Farmer Sep 15 '20 at 15:02
  • 1
    I think you should stick around 10k-20k, if you want higher number, you can use with `setTimeout` – namgold Sep 15 '20 at 15:37
  • Thanks again mate! – Digital Farmer Sep 15 '20 at 15:43