zoukankan      html  css  js  c++  java
  • phantomjs 长图截屏

    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 = {1000,height:scrollheight};
            page.render("json2form.png");
            phantom.exit();
        },60000);    
    
    });
    

      

  • 相关阅读:
    08简单推导:手机尾号评分
    07简单推导:生日蜡烛
    06普通推导
    05简单推导:猴子吃桃
    简单推导
    03map用法
    List题目
    02List的使用
    01基础知识
    HDU
  • 原文地址:https://www.cnblogs.com/c-x-a/p/7262360.html
Copyright © 2011-2022 走看看