phantomjs 长图截屏

mac2022-06-30  42

var 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); });

  

转载于:https://www.cnblogs.com/c-x-a/p/7262360.html

最新回复(0)