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?
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?