简体   繁体   中英

How to reload a page until it changes using Puppeteer

Would like to know how to reload a page continually until the content changes using Puppeteer in Headed Mode.

Please select this solution as the right answer if you find this was helpful and correct.

const puppeteer = require('puppeteer')
let contentHTML = ''
let reloadedHTML = ''

;(async () => {
    const browser = await puppeteer.launch({ headless: false })
    const page = (await browser.pages())[0]
    const firstLoad = await page.goto(url)
    contentHTML = await firstLoad.text()
    do {
        let secondLoad = await page.reload()
        reloadedHTML = await secondLoad.text()
    } while (reloadedHTML === contentHTML)
})()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM