title: How to run Puppeteer code in any web browser?
body: <p>I'm trying to do some web scraping with Puppeteer and I need to retrieve the value into a Website I'm building.</p>
  
  <p>I have tried to load the Puppeteer file in the html file as if it was a JavaScript file but I keep getting an error. However, if I run it in a cmd window it works well.</p>
  
  Scraper.js:
  
  <pre><code>getPrice();
  function getPrice() {
      const puppeteer = require('puppeteer');
      void (async () =&gt; {
          try {
              const browser = await puppeteer.launch()
              const page = await browser.newPage()              
              await page.goto('http://example.com') 
              await page.setViewport({ width: 1920, height: 938 })        
              await page.waitForSelector('.m-hotel-info &gt; .l-container &gt; .l-header-section &gt; .l-m-col-2 &gt; .m-button')
              await page.click('.m-hotel-info &gt; .l-container &gt; .l-header-section &gt; .l-m-col-2 &gt; .m-button')
              await page.waitForSelector('.modal-content')
              await page.click('.tile-hsearch-hws &gt; .m-search-tabs &gt; #edit-search-panel &gt; .l-em-reset &gt; .m-field-wrap &gt; .l-xs-col-4 &gt; .analytics-click')
              await page.waitForNavigation();
              await page.waitForSelector('.tile-search-filter &gt; .l-display-none')
              const innerText = await page.evaluate(() =&gt; document.querySelector('.tile-search-filter &gt; .l-display-none').innerText);
              console.log(innerText)
          } catch (error) {
              console.log(error)
          }
  
      })()
  }
  </code></pre>
  
  index.html:
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;&lt;/head&gt;
    &lt;body&gt;
      &lt;script src="../js/scraper.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The expected result should be this one in the console of Chrome:</p>
  
  <p><img src="https://i.imgur.com/BC3zVKQ.png" alt=""></p>
  
  <p>But I'm getting this error instead:</p>
  
  <p><img src="https://i.imgur.com/72NnLua.png" alt="">
  <img src="https://i.imgur.com/r375JSh.png" alt=""></p>
  
  <p>What am I doing wrong?</p>