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"); }); }); //根据截图输入验证码到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();
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。
专注于为中小企业提供成都网站设计、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业玄武免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。