title: Scraping the same page forever using puppeteer
body: <p>Doing <strong>scraping</strong>. How can I stay on a page and read the content to search for data every xx seconds without refresh the page? I use this way but the pc crashes after some time. Any ideas on how to make it efficient? I would like to achieve it without using while (true). The readOdds function does not always delay the same time.</p>
  <pre><code>//...
  while(true){
     const html = await page.content();
     cant = await readOdds(html); // some code with the html
     console.info('Waiting 5 seconds to read again...');
     await page.waitFor(5000);
  }
  </code></pre>
  <p>this is a section</p>
  <pre><code>async function readOdds(htmlPage){
      try {
          var savedat = functions.mysqlDateTime(new Date());
          var pageHtml=htmlPage.replace(/(\r\n|\n|\r)/gm,&quot;&quot;);
          var exp_text_all = /&lt;coupon-section(.*?)&lt;\/coupon-section&gt;/g;
          var leagueLinksMatches = pageHtml.match(exp_text_all);
          var cmarkets = 0;
  
          let reset = await mysqlfunctions.promise_updateMarketsCount(cmarkets, table_markets_count, site);
          console.log(reset);
  
          if(leagueLinksMatches == null){
              return cmarkets;
          }
          for (let i = 0; i &lt; leagueLinksMatches.length; i++) {
              const html = leagueLinksMatches[i];
              var expc = /class=&quot;title ellipsis-text&quot;&gt;(.*?)&lt;\/span/g;
              var nameChampionship = functions.getDataInHtmlCode(String(html).match(expc)[0]);
  
              var idChampionship = await mysqlfunctions.promise_db_insert_Championship(nameChampionship, gsport, table_championship);
             
  
              var exp_text = /&lt;ui-event-line(.*?)&lt;\/ui-event-line&gt;/g;
              var text = html.match(exp_text);
              // console.info(text.length);
  
              for (let index = 0; index &lt; text.length; index++) {
                  const element = text[index];               
  .... 
    
  </code></pre>