Phantomjs | PhantomJS

设置phantomjs环境变量【也可直接使用phantomjs目录下的执行文件】
直接通过访问php文件执行/通过cmd命令行执行【phantomjs phantom_script.js】
直接命令行执行phantom_script.js即可【phantomjs phantom_script.js】
$phantomScript = './phantom_script.js';
$command = 'phantomjs ' . $phantomScript;
$output = shell_exec($command);
echo 'Screenshot saved at: ' . trim($output);
var page = require('webpage').create();
page.viewportSize = { width: 900, height: 600 };
var url = 'https://www.kancloud.cn/manual/thinkphp6_0/1037479';
var timestamp = new Date().getTime();
var savePath = './phantomimg/'+timestamp+'.png';
function takeScreenshot() {
page.open(url, function(status) {
if (status === 'success') {
console.log('Unable to load the page.');