Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to realize the screenshot of a web page with casperjs

Shulou Source: shulou.com Published: 2022-06-01 18:49:49 10月04日 Update

本篇文章为大家展示了使用casperjs怎么实现网页截图,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

1.安装casperjs

下载之后解压到安装目录,配置环境变量

2.进入系统命令行

新建一个测试脚本test.js

//登陆人人代码var casper = require('casper').create(); phantom.outputEncoding="gbk";casper.start('http://www.renren.com', function() { this.fill('form[id="loginForm"]', { 'email': '***********', 'password': '*********' }, false);});casper.then(function() { this.click('input[class="input-submit login-btn"]'); this.echo('clicked...'); });casper.then(function() { this.wait(3000,function() { this.capture("renren.png"); });});casper.then(function() { this.echo(this.getTitle());});casper.run();

3.进入测试脚本所在文件夹

运行命令

casperjs test.js上述内容就是使用casperjs怎么实现网页截图,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。

Tags: Screenshots web pages content commands skills knowledge scripts tests concise concise everyone code variables that is location files folders articles more environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Xiaomi Shulou Tech Info Linux