Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

385
Visualizações
Uncaught Error: Evaluation failed: ReferenceError: lineBaseSelector is not defined

index.js

(async () => {

        await global.initialize();

        let lineCount = await global.count();
        let globalData = [];
        let childNum = null;
        let lineBaseSelector = null;
         

        for(let i = 1; i < lineCount; i++)
        {
            childNum = i + 1;
            lineBaseSelector = '#alx-content > div.row-fluid.TopSites.AlexaTool.padding20 > section.page-product-content.summary.padding20 > span > span > div > div > div > div:nth-child(' + `${childNum}` + ')';
            let details = await global.getDetails(lineBaseSelector);
            globalData.push(details);
        }

global.js

getDetails: async (lineBaseSelector) => {

        let url = await page.url();

        await page.waitForSelector(lineBaseSelector);

        let details = await page.evaluate(() => {
            return {
                rank: document.querySelector('div[class="td"]').innerText,
                name: document.querySelector('p > a').innerText,
                url: document.querySelector('p > a').getAttribute('href')
            }
        });

        return details;

    },

LineBaseSelector changes dynamically and I want to get every data in which belongs to these selectors as a list. But the data list which I get consists of just the first data. There are 50 datas but I can get just the first one 50 times. I also tried changing the querySelector as "rank: document.querySelector(lineBaseSelector + 'div[class="td"]').innerText," but I had an error called Uncaught Error: Evaluation failed: ReferenceError: lineBaseSelector is not defined. Please help me to solve this. Thank you so much.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda