Recommand · August 7, 2021 0

Puppeteer clicking link in a span element

Hello I am trying to parse a manga site and save all the pages, I have the code working to run through the page saving the images.

I am having trouble clicking on a link that goes to the next page. Working with Node and using puppeteer. Been stuck on this for a more than I care to admit. Thought I would be able to just use document.querySelectorAll("") to get the span in the link.

Included the relevant code for trying to get the next page and html I am trying to click the NEXT CHAPTER link on.

<div class="col-md-6 prev-post">
  <a class="" href="">
     <span class="next-prev-text">PREVIOUS CHAPTER </span>

<div class="col-md-6 next-post">
  <a class="" href="">
       <span class="next-prev-text">NEXT CHAPTER</span>

(async () => {
        const browser = await puppeteer.launch();
        const page = await browser.newPage();

        //starting page
        await page.goto(

        console.log("page has loaded")

        const chapter = await page.evaluate(() => {
            const pages = Array.from(
            ).map((image) => image.getAttribute("src"));

            return pages

        fs.writeFileSync("./data.json", JSON.stringify(chapter));
        console.log("File is created!");

        const nextPage = await page.evaluate(() => {
            var obj = document.querySelectorAll("");

            return obj[1];

        await page.waitForNavigation();

        await browser.close();


Appreciate any help!