Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- console.log('getting browser');
- const browser = await puppeteer.launch({ headless: true, slowMo: 100, args: ['--no-sandbox', '--disable-setuid-sandbox', '--single-process']});
- console.log('opening new page');
- page = await browser.newPage();
- console.log('page opened');
- await page.setViewport({ width: 1413, height: 749 });
- console.log('viewport set');
- await page.setUserAgent(config.USER_AGENT);
- console.log('userAgent set');
- await page.goto(msg.data.url, {timeout: 0, waitUntil: ['domcontentloaded']});
- console.log('succesfully connected to ', msg.data.url);
- let uniqueShot;
- let newShot = await page.screenshot({encoding: 'base64'});
- shotInterval = setInterval(async function () {
- let newShot = await page.screenshot({encoding: 'base64'});
- if (newShot !== uniqueShot) {
- uniqueShot = newShot;
- ws.send(JSON.stringify({title: 'SCREENSHOT', data: uniqueShot}));
- }
- }, 1000);
- } catch (e) {
- console.log(e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement