SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2.     console.log('getting browser');
  3.     const browser = await puppeteer.launch({ headless: true, slowMo: 100,  args: ['--no-sandbox', '--disable-setuid-sandbox', '--single-process']});
  4.     console.log('opening new page');
  5.     page = await browser.newPage();
  6.     console.log('page opened');
  7.     await page.setViewport({ width: 1413, height: 749 });
  8.     console.log('viewport set');
  9.     await page.setUserAgent(config.USER_AGENT);
  10.     console.log('userAgent set');
  11.     await page.goto(msg.data.url, {timeout: 0, waitUntil: ['domcontentloaded']});
  12.     console.log('succesfully connected to ', msg.data.url);
  13.  
  14.     let uniqueShot;
  15.  
  16.     let newShot = await page.screenshot({encoding: 'base64'});
  17.     shotInterval =  setInterval(async function () {
  18.         let newShot = await page.screenshot({encoding: 'base64'});
  19.         if (newShot !== uniqueShot) {
  20.             uniqueShot = newShot;
  21.             ws.send(JSON.stringify({title: 'SCREENSHOT', data: uniqueShot}));
  22.         }
  23.     }, 1000);
  24.  
  25. } catch (e) {
  26.     console.log(e);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top