如何使用 Puppeteer 重新加载页面直到它发生变化
How to reload a page until it changes using Puppeteer
想知道如何在 Headed 模式下使用 Puppeteer 不断重新加载页面,直到内容发生变化。
如果您认为此解决方案有用且正确,请select将此解决方案作为正确答案。
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)
})()
想知道如何在 Headed 模式下使用 Puppeteer 不断重新加载页面,直到内容发生变化。
如果您认为此解决方案有用且正确,请select将此解决方案作为正确答案。
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)
})()