phantomjs open url with proxy | phantomjs使用代理打开连接
"use strict"; var page = require('webpage').create(), system = require('system'), host, port, address; if (system.args.length < 4) { console.log('Usage: openurlwithproxy.js <proxyHost> <proxyPort> <URL>'); phantom.exit(1); } else { host = system.args[1]; port = system.args[2]; address = system.args[3]; phantom.setProxy(host, port, 'manual', '', ''); page.open(address, function (status) { if (status !== 'success') { console.log('FAIL to load the address "' + address + '" using proxy "' + host + ':' + port + '"'); } else { console.log('Page title is ' + page.evaluate(function () { return document.title; })); } phantom.exit(); }); }
本文介绍如何使用PhantomJS结合代理服务器打开指定网址,并获取页面标题。通过设置代理主机、端口及目标URL,实现自动化网页抓取。
7460

被折叠的 条评论
为什么被折叠?



