标签:phantomjs
1.下载phantomjs.exe 下载地址:
https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-windows.zip
http://zhouhua.qiniudn.com/work/nodejs/phantomjs.zip
2.安装phantomjs.exe, 对这个这执行性文件 设置环境变量如图
3.创建一个test.js文件
var page = require('webpage').create(),
system = require('system'),
t,address; //获取保存名称和要生成的网址
if (system.args.length === 1) {
console.log('url loss');
phantom.exit();
} else {
t = Date.now();
address = system.args[1];
page.open(address, function(success){
if(success==='success'){
console.log('success');
page.render('D:/'+t+'.png'); //图片保存路径 @可写权限
phantom.exit();
}else{
console.log('error');
phantom.exit();
}
});
}
//eq: http://localhost/cwb.php?url=http://www.ktuo.cn
$url = $_GET['url'];
exec("phantomjs D:/dapeng/test.js ".$url,$out); //运行js文件
print_r($out);标签:phantomjs
原文地址:http://blog.csdn.net/eadoucn/article/details/42421821