phantomjs 长图截屏
2021-06-18 12:02
标签:json2 webp tin ons webkit phantomjs div on() func phantomjs 长图截屏 标签:json2 webp tin ons webkit phantomjs div on() func 原文地址:http://www.cnblogs.com/c-x-a/p/7262360.htmlvar page = require(‘webpage‘).create();
var url = ‘http://cardloan9.hateblo.jp/‘;
page.settings = {
userAgent:"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36",
javascriptEnabled: true,
loadImages: true
};
page.open(url, function (status)
{
if (status != "success")
{
console.log(‘FAIL to load the address‘);
phantom.exit();
}
var scrollheight= page.evaluate(function()
{
//此函数在目标页面执行的,上下文环境非本phantomjs,所以不能用到这个js中其他变量
return document.body.scrollHeight;
});
window.setTimeout(function ()
{
console.log( ‘scrollheight:‘+ scrollheight);
page.viewportSize = {width:1000,height:scrollheight};
page.render("json2form.png");
phantom.exit();
},60000);
});