BlueGit

blue-star danique-bot

Files

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

openurlwithproxy.js

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
openurlwithproxy.js 779 B Download Raw
1"use strict";
2var page = require('webpage').create(),
3 system = require('system'),
4 host, port, address;
5
6if (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}