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

449
Views
Node JS Puppeteer: Refresh page elements after click without reloading webpage

I'm looking to get the list of songs on a web page under a particular genre. In my code, I'm using puppeteer to select a filter option which should change the data held in the elements where the list of songs appear. Upon running my code, the webpage displays the newly selected genre but doesn't update the list of songs. I tried page.reload() but that took me back to the default webpage before clicking the filters.

EDIT: To provide more detail, I'm trying to scrape genius.com to get a list of all rap songs. I've created a work around which uses threading but it only works sometimes and I've tried rearranging the code a few times but nothing seems to have worked.

console.log("Rap songs");
    const filter = await page.$$(
      ".SquareManySelects__Option-sc-1kktot3-5.eLlkRP"
    );

    
    for (let i = 0; i < filter.length; i++) {
      const name = await filter[i].$eval(
        ".SquareSelectOption__Container-h4rr3o-0.gMvRPT",
        (v) => v.textContent
      );

      if (name == "Rap") {
        console.log({
          name,
        });

        // ***************** WORIKING WITH THREADING ERROR *********************
        await Promise.all([
          page.waitForSelector(
            ".SquareSelectOption__Container-h4rr3o-0.gMvRPT"
          ),
          filter[i].click(),
        ]);

        // ***************** WORIKING WITH THREADING ERROR *********************
        break;
      }
    }
    await page.waitForTimeout(3000);

    //  TESTING
    const reviewElements = await page.$$(
      ".ChartSongdesktop__CoverAndTitle-sc-18658hh-0.jzapEV"
    );

    for (let i = 0; i < reviewElements.length; i++) {
      const name = await reviewElements[i].$eval(
        ".ChartSongdesktop__Title-sc-18658hh-3.fODYHn",
        (v) => v.textContent
      );

      console.log({
        name,
      });
    }
    console.log("Done");
  },

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!