const puppeteer = require('puppeteer'); const getQueue = require('./queue'); var page; var previousQueue = null; async function processData(res) { // get current queue const pageContent = await page.content(); const currentQueue = await getQueue(pageContent); // convert queues to Json const currentQueueJson = await JSON.stringify(currentQueue); const previousQueueJson = await JSON.stringify(previousQueue); // comapre queues console.log(currentQueueJson == previousQueueJson); // console.log(previousQueueJson); // console.log(currentQueueJson); // console.log('\n\n'); // set previous queue = current queue; previousQueue = currentQueue; return; } async function main() { // get page const browser = await puppeteer.launch({ args: ['--no-sandbox'], headless: true }); page = await browser.newPage(); await page.goto('https://example.com'); // listen for websocket const cdp = await page.target().createCDPSession(); await cdp.send('Network.enable'); await cdp.send('Page.enable'); cdp.on('Network.webSocketFrameReceived', processData); } main()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)