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