title: I'm trying to scrap data from a website and getting back basic HTML with JS function in the body
body: <p><strong>Hi everyone,</strong></p>
  <p>I'm playing around with Node.js and cheerio package as part of my node.js learning and im trying to build a web scrapper that will get the title and the price of an item from a shopping site but when I try to console.log the html variable it returns a basic html structure with some Js functions that are trying to prevent the scraping.</p>
  <p>my code:</p>
  <pre><code>const needle = require('needle')
  const http = require('http')
  const cheerio = require(&quot;cheerio&quot;)
  
  needle.get('https://ksp.co.il/web/item/130984', (error, response, html) =&gt; {
      if (!error &amp;&amp; response.statusCode == 200){
          const $ = cheerio.load(html)
  
          
     
  
          console.log(html)
  
          http.createServer(function (req, res) {
              res.writeHead(200, {'Content-Type': 'text/html'});
              res.write(html)
              res.end();
            }).listen(3000);
              
  
      }
  })
  </code></pre>
  <p><strong>I guess it's some kind of protection layer from scrapers but this what i get as a result:</strong></p>
  <pre><code>&lt;html lang=&quot;he&quot;&gt;
  
  &lt;head&gt;
      &lt;meta charset=&quot;utf-8&quot; /&gt;
      &lt;link rel=&quot;icon&quot; id=&quot;header-icon&quot; href=&quot;/web/favicon.ico&quot;&gt;
      &lt;link rel=&quot;canonical&quot; id=&quot;header-canonical&quot;&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1&quot; /&gt;
      &lt;meta name=&quot;description&quot; content=&quot;מעל 38,000 מוצרים: מחשבים סלולר, בשמים, למטבח, למשרד טיפוח, פארם, צעצועים, נעלים ומיזוג&quot; /&gt;
      &lt;link rel=&quot;manifest&quot; href=&quot;/web/manifest.json&quot; /&gt;
      &lt;script src='https://ksp.co.il/_cache/dictionary_site_only/all.js?ts=1640275687'&gt;&lt;/script&gt;
      &lt;script src=&quot;/web/encoding.min.js&quot;&gt;&lt;/script&gt;
      &lt;script&gt;
          ! function() {
              if (&quot;function&quot; == typeof window.CustomEvent) return !1;
  
              function t(t, e) {
                  e = e || {
                      bubbles: !1,
                      cancelable: !1,
                      detail: void 0
                  };
                  var n = document.createEvent(&quot;CustomEvent&quot;);
                  return n.initCustomEvent(t, e.bubbles, e.cancelable, e.detail), n
              }
              t.prototype = window.Event.prototype, window.CustomEvent = t
          }()
          
          
  
      &lt;/script&gt;
      &lt;script src='https://ksp.co.il/_cache/menu_dev/menu.js?ts=1640280140'&gt;&lt;/script&gt;
      &lt;style&gt;
          .lang_he svg.revert {
              transform: scaleX(-1)
          }
  
          * {
              box-sizing: border-box
          }
  
          a:visited {
              color: inherit
          }
  
      &lt;/style&gt;
      &lt;title&gt;KSP&lt;/title&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w300en.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w400en.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w600en.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w700en.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w800en.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w300he.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w400he.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w600he.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w700he.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;preload&quot; href=&quot;/web/fonts/Assistant/w800he.woff2&quot; as=&quot;font&quot; crossorigin=&quot;anonymous&quot;&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;/web/fonts/Assistant/index.css&quot;&gt;
      &lt;script&gt;
          ! function(e, t, a, n, g) {
              e[n] = e[n] || [], e[n].push({
                  &quot;gtm.start&quot;: (new Date).getTime(),
                  event: &quot;gtm.js&quot;
              });
              var m = t.getElementsByTagName(a)[0],
                  r = t.createElement(a);
              r.async = !0, r.src = &quot;https://www.googletagmanager.com/gtm.js?id=GTM-59D9ZCV&quot;, m.parentNode.insertBefore(r, m)
          }(window, document, &quot;script&quot;, &quot;dataLayer&quot;)
  
      &lt;/script&gt;
      &lt;link href=&quot;/web/static/css/2.f825bd5a.chunk.css&quot; rel=&quot;stylesheet&quot;&gt;
      &lt;link href=&quot;/web/static/css/main.4e4460ee.chunk.css&quot; rel=&quot;stylesheet&quot;&gt;
  &lt;/head&gt;
  
  &lt;body style=&quot;overflow-x:hidden&quot;&gt;&lt;noscript&gt;&lt;iframe src=&quot;https://www.googletagmanager.com/ns.html?id=GTM-59D9ZCV&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;display:none;visibility:hidden&quot;&gt;&lt;/iframe&gt;&lt;/noscript&gt;&lt;noscript&gt;You need to enable JavaScript to run this app.&lt;/noscript&gt;
      &lt;div&gt;
          &lt;div id=&quot;root&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=UA-109261-1&quot;&gt;&lt;/script&gt;
      &lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=AW-1032006858&quot;&gt;&lt;/script&gt;
      &lt;script&gt;
          function gtag() {
              dataLayer.push(arguments)
          }
          window.dataLayer = window.dataLayer || [], gtag(&quot;js&quot;, new Date)
  
      &lt;/script&gt;
      &lt;script&gt;
          ! function(e, t, n, c, o, a, f) {
              e.fbq || (o = e.fbq = function() {
                  o.callMethod ? o.callMethod.apply(o, arguments) : o.queue.push(arguments)
              }, e._fbq || (e._fbq = o), o.push = o, o.loaded = !0, o.version = &quot;2.0&quot;, o.queue = [], (a = t.createElement(n)).async = !0, a.src = &quot;https://connect.facebook.net/en_US/fbevents.js&quot;, (f = t.getElementsByTagName(n)[0]).parentNode.insertBefore(a, f))
          }(window, document, &quot;script&quot;), fbq(&quot;init&quot;, &quot;1179615532183839&quot;), fbq(&quot;track&quot;, &quot;PageView&quot;)
  
      &lt;/script&gt;&lt;noscript&gt;&lt;img height=&quot;1&quot; width=&quot;1&quot; style=&quot;display:none&quot; src=&quot;https://www.facebook.com/tr?id=1179615532183839&amp;ev=PageView&amp;noscript=1&quot; /&gt;&lt;/noscript&gt;
      &lt;script&gt;
          ! function(e) {
              function r(r) {
                  for (var n, l, f = r[0], i = r[1], a = r[2], p = 0, s = []; p &lt; f.length; p++) l = f[p], Object.prototype.hasOwnProperty.call(o, l) &amp;&amp; o[l] &amp;&amp; s.push(o[l][0]), o[l] = 0;
                  for (n in i) Object.prototype.hasOwnProperty.call(i, n) &amp;&amp; (e[n] = i[n]);
                  for (c &amp;&amp; c(r); s.length;) s.shift()();
                  return u.push.apply(u, a || []), t()
              }
  
              function t() {
                  for (var e, r = 0; r &lt; u.length; r++) {
                      for (var t = u[r], n = !0, f = 1; f &lt; t.length; f++) {
                          var i = t[f];
                          0 !== o[i] &amp;&amp; (n = !1)
                      }
                      n &amp;&amp; (u.splice(r--, 1), e = l(l.s = t[0]))
                  }
                  return e
              }
              var n = {},
                  o = {
                      1: 0
                  },
                  u = [];
  
              function l(r) {
                  if (n[r]) return n[r].exports;
                  var t = n[r] = {
                      i: r,
                      l: !1,
                      exports: {}
                  };
                  return e[r].call(t.exports, t, t.exports, l), t.l = !0, t.exports
              }
              l.m = e, l.c = n, l.d = function(e, r, t) {
                  l.o(e, r) || Object.defineProperty(e, r, {
                      enumerable: !0,
                      get: t
                  })
              }, l.r = function(e) {
                  &quot;undefined&quot; != typeof Symbol &amp;&amp; Symbol.toStringTag &amp;&amp; Object.defineProperty(e, Symbol.toStringTag, {
                      value: &quot;Module&quot;
                  }), Object.defineProperty(e, &quot;__esModule&quot;, {
                      value: !0
                  })
              }, l.t = function(e, r) {
                  if (1 &amp; r &amp;&amp; (e = l(e)), 8 &amp; r) return e;
                  if (4 &amp; r &amp;&amp; &quot;object&quot; == typeof e &amp;&amp; e &amp;&amp; e.__esModule) return e;
                  var t = Object.create(null);
                  if (l.r(t), Object.defineProperty(t, &quot;default&quot;, {
                          enumerable: !0,
                          value: e
                      }), 2 &amp; r &amp;&amp; &quot;string&quot; != typeof e)
                      for (var n in e) l.d(t, n, function(r) {
                          return e[r]
                      }.bind(null, n));
                  return t
              }, l.n = function(e) {
                  var r = e &amp;&amp; e.__esModule ? function() {
                      return e.default
                  } : function() {
                      return e
                  };
                  return l.d(r, &quot;a&quot;, r), r
              }, l.o = function(e, r) {
                  return Object.prototype.hasOwnProperty.call(e, r)
              }, l.p = &quot;/web/&quot;;
              var f = this.webpackJsonpcode = this.webpackJsonpcode || [],
                  i = f.push.bind(f);
              f.push = r, f = f.slice();
              for (var a = 0; a &lt; f.length; a++) r(f[a]);
              var c = i;
              t()
          }([])
  
      &lt;/script&gt;
      &lt;script src=&quot;/web/static/js/2.159a3d73.chunk.js&quot;&gt;&lt;/script&gt;
      &lt;script src=&quot;/web/static/js/main.1ab08410.chunk.js&quot;&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p>Any idea how can i overcome this ?
  <strong>Thanks everyone</strong></p>