Skip to content

how to do save multiple page data in once?Please #1619

@nijun008

Description

@nijun008

I want to... ,open a page, get the page data, then click next page, continue to get page data, all the way to the target page,
my code for now

nightmare
  .goto(`https://www.appinn.com/`)
  .wait('.latestPost')
  .wait(() => {
    window.htmlArr = window.htmlArr || []
    
    if (!document.querySelector('.latestPost')) {
      return false
    }

    window.htmlArr.push(document.querySelector('#latest-posts').innerHTML)

    let currentPage = document.querySelector('.page-numbers.current')

    if (currentPage && currentPage.innerHTML == 5) {
      return true
    }

    let nextBtn = document.querySelector(".nav-links .next")
    if (nextBtn) {
      nextBtn.click()
      return false
    }
    return true
  })
  .evaluate(() => {
    return window.htmlArr
  })
  .end()
  .then(htmlList => {
    conosle.log(htmlList )
  })

htmlList only last page data, none others page data

What should I do? thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions