I wrote a function based on MutationObServer :
module.exports.crawler = async(page, link)=>{
try {
await page.goto(link, { waitUntil: 'networkidle2' })
await page.waitForSelector('#dbp')
await page.waitForTimeout(10000)
await page.exposeFunction('puppeteerLogMutation', () => {
console.log('Mutation Detected: A child node has been added or removed.');
});
tables = await page.evaluate(async()=>{
target = document.querySelector("#d02");
const observer = new MutationObserver( mutations => {
console.log(mutations)
});
observer.observe(target, { childList: true });
return data
})
console.log(tables)
await page.close()
} catch (error) {
console.log(error)
}
target variable is changing every 20 seconds . I want to detect the changes . but this is not working.any idea?