var casper = require('casper').create({
clientScripts:["jquery.js"],
pageSettings:{
// userAgent: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; Tablet PC 2.0; .NET4.0E)'
userAgent:'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3)'
}
});
var fs = require('fs');
var code;
casper.start('http://www.jsjtxx.com/spage/Beginner-Login.html');
casper.then(function() {
this.wait(5000,function() {
this.echo("I've waited for 5 seconds again");
});
});
//截圖登錄頁面
casper.then(function(){
if (this.exists("#ttt")) {
this.capture("code.jpeg");
};
});
casper.then(function() {
this.wait(30000,function() {
this.echo("I've waited for 30 seconds again ,please input code");
});
});
//根據(jù)截圖輸入驗(yàn)證碼到code.txt文件并讀取
casper.then(function(){
if (fs.exists("code.jpeg") && fs.exists("code.txt")) {
code = fs.read("code.txt");
}
});
casper.then(function() {
this.wait(5000,function() {
this.echo("I've waited for 5 seconds again ,please input code");
});
});
casper.then(function(){
this.fill('form[id="fmLogin"]',{
'deptId':'320300',
'loginId':'×××號',
'passwd':'密碼',
'authCode':code
},false);
});
casper.then(function(){
this.click(".login_buton");
this.capture("login.jpeg");
});
casper.then(function() {
this.wait(10000,function() {
this.echo("I've waited for 10 seconds again");
});
});
casper.then(function() {
this.echo('new location is ' + this.getCurrentUrl());
this.capture("main.jpeg");
});
casper.then(function() {
if (this.exists("#plan")) {
if (this.exists("#studyForm1 .btn_iskt2 span")) {
this.click("#studyForm1 .btn_iskt2 span");
this.echo("exists");
}else{
this.echo("not exists");
}
}else{
this.echo("not exists");
}
});
casper.then(function() {
this.wait(10000,function() {
this.echo("I've waited for 10 seconds again");
});
});
casper.then(function() {
this.capture("video.jpeg");
});
casper.run();創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國云服務(wù)器,動態(tài)BGP最優(yōu)骨干路由自動選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動現(xiàn)已開啟,新人活動云服務(wù)器買多久送多久。

分享名稱:casperjs模擬登錄-駕校登錄-創(chuàng)新互聯(lián)
文章來源:http://chinadenli.net/article8/sheop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、網(wǎng)站營銷、App設(shè)計、網(wǎng)站內(nèi)鏈、商城網(wǎng)站、移動網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容