casperjs模拟登录-驾校登录
2017-02-23 09:46
295 查看
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();
相关文章推荐
- casperjs配合phantomjs实现自动登录百度,模拟点击等等操作 - 怕虎在线www.ipahoo.com图文教程 - 怕虎在线
- 用casperjs模拟登录,支持多个账户登录
- casperjs模拟登录-jd无验证码登录
- casperjs模拟登录-jd无验证码签到
- 多个账户模拟登录---c#异步模拟登录网站并采集网页
- (最新)HttpClient4模拟登录腾讯微博
- 新浪微博模拟登录(Python+RSA加密算法)附源代码(转)
- PHP模拟QQ登录的方法
- 23. XML 解析 / HTTP 请求方法 / 模拟登录 / MD5
- hp 使用curl模拟登录discuz以及模拟发帖(含formhash的实现)
- C#使用tesseract3.02识别验证码模拟登录
- Python模拟登录东北大学校园IP网关
- HttpClient4模拟登录腾讯微博及分享功能
- 通过scrapy,从模拟登录开始爬取知乎的问答数据
- PreparedStatement,注册攻击,模拟用户登录
- VUE DEMO 之模拟登录 个人中心页面之间数据传值
- scrapy 通过FormRequest模拟登录再继续
- scrapy爬虫之模拟登录豆瓣
- Python模拟登录csdn代码
- Java httpclient 模拟NTLM域登录