Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/loadurlwithoutcss.js
164 views
1
var page = require('webpage').create(),
2
system = require('system');
3
4
if (system.args.length < 2) {
5
console.log('Usage: loadurlwithoutcss.js URL');
6
phantom.exit();
7
}
8
9
var address = system.args[1];
10
11
page.onResourceRequested = function(requestData, request) {
12
if ((/http:\/\/.+?\.css/gi).test(requestData['url']) || requestData.headers['Content-Type'] == 'text/css') {
13
console.log('The url of the request is matching. Aborting: ' + requestData['url']);
14
request.abort();
15
}
16
};
17
18
page.open(address, function(status) {
19
if (status === 'success') {
20
phantom.exit();
21
} else {
22
console.log('Unable to load the address!');
23
phantom.exit();
24
}
25
});
26