phantom.outputEncoding = "gbk";
var fs=require("fs") //var data = fs.read("cookie.txt")
//phantom.cookies = JSON.parse(data) var casper = require("casper").create({
clientScripts: ["jquery.min.js"],
verbose: true,
// logLevel: 'debug',
safeLogs: true,
viewportSize:{width: 1024, height: 768},
pageSettings: {
// loadImages: false, // The WebPage instance used by Casper will
// loadPlugins: false, // use these settings
userAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36'
}
}) //新建一个页面 casper.start('http://www.cnblogs.com/pick/');
casper.then(function(){
this.evaluate(function() {
$("a:contains('登录')").click()
});
this.wait(1000, function() {
this.echo("I've waited for a second.");
});
})
casper.then(function(){
this.capture('qq2.png');
console.log(210)
this.evaluate(function() {
$("#input1").focus().val("m3m4_ck")
$("#input2").focus().val("保密")
$("#signin").click()
});
this.wait(1000, function() {
this.echo("I've waited for a second.");
});
})
casper.then(function(){
this.capture('qq3.png');
}) casper.then(function(){
this.wait(2000,function(){
this.capture('qq4.png');
var cookies = JSON.stringify(phantom.cookies)
fs.write("cookie.txt", cookies, 644)
})
// this.fill('#Main form', {
// 'text': 'm3m4_ck',
// 'password': '907167'
// }, false);
// this.click("#signin")
//
//
// this.wait(5000,function(){
// var cookies = JSON.stringify(phantom.cookies)
// fs.write("cookie.txt", cookies, 644)
// this.capture('qq2.png');
// }) }); casper.run();

  

05-26 19:00