BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / phantomjs-prebuilt / lib / phantom / examples / loadurlwithoutcss.js

loadurlwithoutcss.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
loadurlwithoutcss.js 715 B Download Raw
1"use strict";
2var page = require('webpage').create(),
3 system = require('system');
4
5if (system.args.length < 2) {
6 console.log('Usage: loadurlwithoutcss.js URL');
7 phantom.exit();
8}
9
10var address = system.args[1];
11
12page.onResourceRequested = function(requestData, request) {
13 if ((/http:\/\/.+?\.css/gi).test(requestData['url']) || requestData.headers['Content-Type'] == 'text/css') {
14 console.log('The url of the request is matching. Aborting: ' + requestData['url']);
15 request.abort();
16 }
17};
18
19page.open(address, function(status) {
20 if (status === 'success') {
21 phantom.exit();
22 } else {
23 console.log('Unable to load the address!');
24 phantom.exit();
25 }
26});