标签:int 通过 bpa settings 分享 als detail messages 描述
var casper = require(‘casper‘).create({
clientScripts: [
‘includes/jquery.js‘, // These two scripts will be injected in remote
‘includes/underscore.js‘ // DOM on every request
],
pageSettings: {
loadImages: false, // The WebPage instance used by Casper will
loadPlugins: false // use these settings
},
logLevel: "info", // Only "info" level messages will be logged
verbose: true // log messages will be printed out to the console
});
var casper = require(‘casper‘).create();
casper.options.waitTimeout = 1000;
实例:
代码:
var casper = require(‘casper‘).create();
casper.start(‘http://www.baidu.com/‘, function() {
this.echo("Hello Baidu. I am here now.");
});
casper.run();
实例:
代码:
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.
});
运行结果:
实例:
代码:
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();
运行结果:
获取当前访问的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();
结果:
转载:http://blog.csdn.net/Kandy_Ye/article/details/47355169
标签:int 通过 bpa settings 分享 als detail messages 描述
原文地址:http://www.cnblogs.com/c-x-a/p/7267063.html