Page MenuHomePhabricator
Paste P5823

do-tool.js
ActivePublic

Authored by zhuyifei1999 on Jul 30 2017, 5:02 PM.
Tags
None
Referenced Files
F8908887: do-tool.js
Jul 30 2017, 5:02 PM
Subscribers
None
var page = require('webpage').create(),
fs = require('fs'),
system = require('system'),
address;
page.onError = function(msg, trace) {
var msgStack = ['ERROR: ' + msg];
if (trace && trace.length) {
msgStack.push('TRACE:');
trace.forEach(function(t) {
msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
});
}
console.error(msgStack.join('\n'));
};
page.onResourceRequested = function(requestData, networkRequest) {
console.log(requestData.url);
};
if (system.args.length != 2) {
console.log('Usage ERROR');
phantom.exit(1);
} else {
address = system.args[1];
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit(1);
} else {
window.setTimeout(function () { phantom.exit(); }, 1000);
}
});
}