实例:
代码:
var casper = require('casper').create(); casper.start('http://www.baidu.com/', function() { this.echo("Hello Baidu. I am here now."); }); casper.run(); 12345运行结果:实例:
代码:
var casper = require('casper').create(); casper.start('http://www.baidu.com/', function() { this.echo("Hello Baidu. I am here now."); }); casper.run(function() { this.echo('So the whole suite ended.'); this.exit(); // <--- don't forget me! this.echo('After exit().'); //<----Don't be executed. }); 123456789运行结果:
实例:
代码:
var casper = require('casper').create(); casper.start('http://www.baidu.com/'); casper.then(function() { this.echo("I'm in Baidu."); }); casper.then(function() { this.echo('I am a freshman.'); }); casper.then(function() { this.echo('It is amazing. Bye!'); }); casper.run(); 1234567891011121314运行结果:
获取当前访问的HTTP response
代码:
var casper = require('casper').create(); casper.start('http://www.baidu.com/'); casper.then(function() { this.echo("HTTP Response Info:"); this.echo("--------------------------------------"); }); casper.then(function(response) { require('utils').dump(response); }); casper.then(function() { this.echo("--------------------------------------"); this.echo("end"); }); casper.run(); 12345678910111213141516结果:
转载:http://blog.csdn.net/Kandy_Ye/article/details/47355169
转载于:https://www.cnblogs.com/c-x-a/p/7267063.html
相关资源:JAVA上百实例源码以及开源项目