1、安装node.js(略)
2、安装npm(略)
3、安装phantomJS
npm install phantomjs -g
phantomjs —version // 查看下版本
npm install webpage //安装webpage包
4、如果phantomJS安装失败,不用纠结,直接下载程序包 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
可以去上面的网站查找并下载最新的程序包,里面包含phantomJS运行的整个环境
tar xvfj phantomjs-2.1.1-linux-x86_64.tar.bz2 //解压
ln -s /root/photo/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/ //创建软连接到运行环境
5、上代码
var page = require('webpage').create(); //加载webpage模块
var system = require('system’), //加载system模块
t,address;
address = system.args[1]; //接收url地址参数
name = system.args[2]; //接收图片名字参数
if (address =