Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/openurlwithproxy.js
164 views
1
var page = require('webpage').create(),
2
system = require('system'),
3
host, port, address;
4
5
if (system.args.length < 4) {
6
console.log('Usage: openurlwithproxy.js <proxyHost> <proxyPort> <URL>');
7
phantom.exit(1);
8
} else {
9
host = system.args[1];
10
port = system.args[2];
11
address = system.args[3];
12
phantom.setProxy(host, port, 'manual', '', '');
13
page.open(address, function (status) {
14
if (status !== 'success') {
15
console.log('FAIL to load the address "' +
16
address + '" using proxy "' + host + ':' + port + '"');
17
} else {
18
console.log('Page title is ' + page.evaluate(function () {
19
return document.title;
20
}));
21
}
22
phantom.exit();
23
});
24
}
25
26