zoukankan      html  css  js  c++  java
  • webshot一款网页快照工具

    webshot

    https://github.com/brenden/node-webshot

    Webshot provides a simple API for taking webpage screenshots. The module is a light wrapper around PhantomJS, which utilizes WebKit to perform the page rendering.

    例子

    A simple url example:

    var webshot = require('webshot');
    
    webshot('google.com', 'google.png', function(err) {
      // screenshot now saved to google.png
    });

    An html example:

    var webshot = require('webshot');
    
    webshot('<html><body>Hello World</body></html>', 'hello_world.png', {siteType:'html'}, function(err) {
      // screenshot now saved to hello_world.png
    });

    Alternately, the screenshot can be streamed back to the caller:

    var webshot = require('webshot');
    var fs      = require('fs');
    
    var renderStream = webshot('google.com');
    var file = fs.createWriteStream('google.png', {encoding: 'binary'});
    
    renderStream.on('data', function(data) {
      file.write(data.toString('binary'), 'binary');
    });

    An example showing how to take a screenshot of a site's mobile version:

    var webshot = require('webshot');
    
    var options = {
      screenSize: {
        width: 320
      , height: 480
      }
    , shotSize: {
        width: 320
      , height: 'all'
      }
    , userAgent: 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_2 like Mac OS X; en-us)'
        + ' AppleWebKit/531.21.20 (KHTML, like Gecko) Mobile/7B298g'
    };
    
    webshot('flickr.com', 'flickr.jpeg', options, function(err) {
      // screenshot now saved to flickr.jpeg
    });

    作用

    给网页拍照, 生成网页照片图, 然后使用图形化比对工具检测图形变化, 进而检测页面变化。

    用于图形并茂的方式, 给网页做介绍, 给用户更好的按照图形的感觉,记忆网站的使用场景。

    例如, 用户看到网页截图中有一个搜索框, 就知道是搜索引擎。

  • 相关阅读:
    常见的eclipse和真机出现的问题
    volley+okhttp封装,一行代码就可访问网络
    android异步任务处理(网络等耗时操作)
    android手机短信获取
    Android从启动到程序运行整个过程的整理
    android中的广播
    图片旋转问题
    Android Satudio的使用记录
    百度地图初学者
    简单的图片上传和下载
  • 原文地址:https://www.cnblogs.com/lightsong/p/10903183.html
Copyright © 2011-2022 走看看