您好,登錄后才能下訂單哦!
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"); }); }); //截圖登錄頁(yè)面 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':'×××號(hào)', '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();
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。