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