Reputation: 8023
My case is to load static content only (the content we get using "wget") using phantomjs and then run some javascript to determine the "title" of the page. I dont need to load the whole page to know its title right?
Tried to use:
page.settings.resourceTimeout = 0;
page.settings.javascriptEnabled = false;
page.settings.loadImages = false;
page.settings.localToRemoteUrlAccessEnabled = false;
page.settings.webSecurityEnabled = false;
but in this case my document.title is not working because my JS is disabled. Justified!
Is there a way to load only static content? Something like
page.open(uri, static = true, ...
Upvotes: 3
Views: 1825
Reputation: 28913
According to this issue you can call request.abort()
inside page.onResourceRequested
. The example given there, to stop all css being loaded, is:
page.onResourceRequested = function(requestData, request) {
if ((/http:\/\/.+?.css/gi).test(requestData['url']) || requestData['Content-Type'] == 'text/css') {
console.log('The url of the request is matching. Aborting: ' + requestData['url']);
request.abort();
}
}
Upvotes: 3