Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nijun008 opened this issue Jan 13, 2021 · 0 comments
Open

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

nijun008 opened this issue Jan 13, 2021 · 0 comments

Comments

@nijun008
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant