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ù)截圖輸入驗證碼到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許可證, 機房獨有T級流量清洗系統(tǒng)配攻擊溯源,準確進行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動現(xiàn)已開啟,新人活動云服務(wù)器買多久送多久。
專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)服務(wù),電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)玄武免費做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。