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

156
Vistas
search a class name in multiple pages and get the urls with that class with javascript

I'm trying to search in an array of urls if there is a class name in any of the pages and get a new array with the urls that have thas class name.

This is what I have:

var urls = ["https://www.url.com/withclass","https://www.url.com/withoutclass"];
var classToFind=document.getElementsByClassName('empty');
var results = [];
 
function findClassURL(url, classempty){
    jQuery.ajax({
        url:      url,
        dataType: 'text',
        type:     'GET',
        complete:  function(classname){
            if(typeof classempty === 'function')
                classempty.apply(this, [classname.all]);
        }
    });
}

for(var i = 0; i < urlsToSearch.length; i++) {
    findClassURL(results.push(urlsToSearch[i]), function() {
        if(all){
            console.log(results + '   ok');
        }
        else {
            console.log(urlsToSearch + '   has products');
        }
    });
}

Right now this gets me an 404 error.

Please help me to know if there is any other way of doing this

Thanks

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

0

Before your for loop, I'd define an empty array to hold your results in (the urls that have the className in them. Like so:

let results = [];

Then, if a given url has the className, you add the url to the results array like so:

results.push(urlsToSearch[i]

Then at the end of your function, return the results like so:

return results;

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