title: Refresh when an element changes on page
body: <p>I try to scrap an element on a website and display it on localhost with Puppeteer (1). But when this element changes, I would like to refresh data without opening a new browser/page with Puppeteer and only when element changes (2).</p>
  
  <p>For my example, I use www.timeanddate.com and the element is time (hours and minutes). For moment, only first part works. I don't have solution for second one.</p>
  
  <p>Please find below, my code.</p>
  
  <p><em>app.js</em></p>
  
  <pre><code>var app = require('express')();
  var server = require('http').createServer(app);
  var io = require('socket.io').listen(server);
  var puppeteer = require('puppeteer');
  
  app.get('/', function(req, res) { 
      res.render('main.ejs');
  });
  
  server.listen(8080);
  
  let scrape = async () =&gt; {
      var browser = await puppeteer.launch({headless: true});
      var page = await browser.newPage();
      await page.goto('https://www.timeanddate.com/worldclock/personal.html');
      await page.waitFor(300);
      //await page.click('#mpo &gt; div &gt; div &gt; div &gt; div.modal-body &gt; div.form-submit-row &gt; button.submit.round.modal-privacy__btn');
  
      var result = await page.evaluate(() =&gt; {
          return document.getElementsByClassName('c-city__hrMin')[0].innerText;
      });
  
      return result;
  };
  
  io.sockets.on('connection', function (socket) {
      scrape().then((value) =&gt; { // it tooks time, a few seconds while page is loading.
          console.log(value);
          socket.emit('refresh', value);
      });
  });
  </code></pre>
  
  <p><em>main.ejs</em></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8" /&gt;
          &lt;title&gt;What time is it?&lt;/title&gt;
          &lt;style&gt;
              a {text-decoration: none; color: black;}
          &lt;/style&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;h1&gt;Welcome !&lt;/h1&gt;
  
          &lt;div id="time"&gt;loading&lt;/div&gt;
  
          &lt;script src="http://code.jquery.com/jquery-1.10.1.min.js"&gt;&lt;/script&gt;
          &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              var socket = io.connect('http://localhost:8080');
  
              socket.on('refresh', function (value) {
                  $('#time').html(value);
              });         
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I try Fiverr but awful experience. I hope it will better here :)</p>
  
  <p>Thank you for helping me.</p>