Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

375
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!