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

    作用

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

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

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

  • 相关阅读:
    tensorflow2.0——tensorboard与预测代码相结合
    tensorflow2.0——tensorboard画图使用
    tensorflow2.0——手写数据集预测完整版
    tensorflow2.0——交叉熵损失应用
    tensorflow2.0——softmax函数
    tensorflow2.0——多层全连接模板
    python基础知识
    day31(模块和包)
    day26(模块 logging 高级用法、collection、random)
    day7 set集合
  • 原文地址:https://www.cnblogs.com/lightsong/p/10903183.html
Copyright © 2011-2022 走看看