Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
How to click a lot of elements in Javascript without errors?

I have been trying to download all USA and CANADA servers here on Nord VPN website: https://nordvpn.com/ovpn/

I tried to manually download it but it is time consuming to scroll down every time and identify each US related servers, so i just wrote simple Javascript that can be run on Chrome Inspect Element Console:

var servers = document.getElementsByClassName("mr-2");
var inc_servers = [];
for (var i = 0; i < servers.length; i++) {
  var main_server = servers[i];
  var server = servers[i].innerText;
  if(server.includes("ca")){
        var parent_server = main_server.parentElement.parentElement;
        parent_server.querySelector(".Button.Button--primary.Button--small").click();
        inc_servers.push(server);
  }
}
console.log(JSON.stringify(inc_servers));

I also wrote simple python script that automatically click "save" file:

while True:
    try:
        app2 = pywinauto.Application().connect(title=u'Save As', found_index=0)
        app2.SaveAs.Save.click()
    except:
        pass

It gets all the elements, it works there, however, when I let javascript click each element, maybe because of too many elements, it returns an error:

VM15575:8 Throttling navigation to prevent the browser from hanging. See https://crbug.com/1038223. Command line switch --disable-ipc-flooding-protection can be used to bypass the protection

Are there any other best alternative for my problem? Or maybe how to fix the error message above? I tried running this command in my command prompt: switch --disable-ipc-flooding-protection

but it returns also an error: 'switch' is not recognized as an internal or external command, operable program or batch file.

I only know basic Javascript and Python. Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So right off the bat, your program is simply downloading files too fast.

Adding a small delay between each file download allows your JavaScript to run.

var servers = document.getElementsByClassName("mr-2");
var inc_servers = [];
for (var i = 0; i < servers.length; i++) {
  var main_server = servers[i];
  var server = servers[i].innerText;
  if(server.includes("ca")){
        var parent_server = main_server.parentElement.parentElement;
        // Add 1 second delay between each download (fast enough on my computer.. Might be too fast for yours.)
        await new Promise(resolve => setTimeout(resolve, 1000));
        parent_server.querySelector(".Button.Button--primary.Button--small").click();


  }
}
// Remove the logging. Just tell the user that it's worked
console.log("Done downloading all files.");

This is more of a temporary solution, but this script seems like it only needs to be run once, so it'll work for now.

(your python code runs fine. Nothing to do there)

Hope this helped.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda