1

How do one scrape a site that has disabled Chrome DevTools?

Using Puppeteer, I have tried to get the departure and arrival time for a particular airline using their respective CSS selector, but have not been successful as the DevTool is disabled.

On a little inspection, similar to what Facebook did, I found out that DevTools, the protocol on which Puppeteer controls the browser is disabled by the website. I can't seem to run any valid JavaScript function in the console.

Please, are there any approach to scraping websites like this?

enter image description here

UPDATE

It turns out that the site loads this JavaScript function below which limits my ability to run any valid JavaScript code in the console.

function preventAction(a) {
  a.preventDefault();
  return false
}
jQuery(function() {
  $(document).on("paste", "input", preventAction);
  $(document).on("drop", "input", preventAction);
  $("html").css({
    userSelect: "none"
  })
});
$(function() {
  var c = 0;
  function b() {
    if (!c) {
      setTimeout(function() {
        console.warn("%cYou are not allowed to use developer tools in Production mode!", "font: 2em sans-serif; color: yellow; background-color: red;")
      }, 1);
      c = 1
    }
    throw "Console is disabled!"
  }
  var a, d = {
    set: function(e) {
      a = e
    },
    get: function() {
      b();
      return a
    }
  };
  console.log("2016 Hitit Computer Services");
  console.warn("%cYou are not allowed to use developer tools in Production mode!", "font: 2em sans-serif; color: #fefefe; background-color: #B5121B; padding: 4px;");
  Object.defineProperty(console, "_commandLineAPI", d);
  Object.defineProperty(console, "__commandLineAPI", d);
  Object.defineProperty(window, "_commandLineAPI", d);
  Object.defineProperty(window, "__commandLineAPI", d);
  Object.defineProperty(window, "console", d)
});

Is there anyway to override the function Object.defineProperty(console,"_commandLineAPI",d) loaded by the site using Puppeteer so I can traverse through the DOM tree using cheerio?

Sean
  • 6,873
  • 4
  • 21
  • 46
Chuks
  • 1,134
  • 11
  • 21
  • 1
    Afaik, there's no such thing as `disabling the developer tools`. It's a feature of the browser. It seems that this is only a console output with some styling. – Harun Yilmaz Feb 16 '20 at 13:18
  • Please see: https://stackoverflow.com/questions/7559409/how-to-disable-browser-developer-tools – Harun Yilmaz Feb 16 '20 at 13:18
  • Sites can't disable neither devtools nor the protocol. Your code must be breaking because of something in the site but we can't help without seeing it. – wOxxOm Feb 16 '20 at 13:35
  • Disabled DevTools, noice! If you block the request to prodRestrictions.min.js you'll find it working again. I wonder what other magic it contains besides the console message. – Jonathan Feb 16 '20 at 13:51

0 Answers0