casperjs模拟登录-jd无验证码登录
2017-02-23 15:25
387 查看
var casper = require('casper').create({ clientScripts:[ 'E:/jquery.js' ] }); var accountLogin = '.login-form .login-tab-r a'; var hidestr = "hide",has_verify = false; casper.start('https://passport.jd.com/new/login.aspx?ReturnUrl=https%3A%2F%2Fwww.jd.com%2F'); casper.then(function(){ this.wait(5000,function() { this.echo("I've waited for 5 seconds again"); }); }); //可删除 casper.then(function() { this.capture("accountlogin1.jpeg"); }); casper.then(function(){ if (this.exists(accountLogin)) { this.echo("exists"); this.click("#content .login-wrap .w .login-form .login-tab-r a"); }else{ this.echo("not exists"); } }); casper.then(function(){ this.wait(2000,function() { this.echo("I've waited for 2 seconds again"); }); }); //可删除 casper.then(function() { this.capture("accountlogin2.jpeg"); }); casper.then(function(){ if (this.exists("#o-authcode")) { this.evaluate(function(){ var oauthcode = document.getElementById("o-authcode"); var classValue = oauthcode.className; if (classValue !=null) { if (classValue.indexOf(hidestr) > 0) { has_verify = false; }else{ this.captureSelector("./jdcode.jpeg","#JD_Verification1"); has_verify = true; } } }); } }); casper.then(function(){ this.wait(2000,function() { this.echo("I've waited for 2 seconds again"); }); }); casper.then(function(){ if (has_verify) { this.echo("需要输入验证码"); }else{ this.fill('form[id="formlogin"]',{ 'loginname':'xxx', 'nloginpwd':'xxx', },true); } }); casper.then(function(){ this.click(".login-btn a"); this.echo("登录中..."); }); 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("jd.jpeg"); }); casper.run();
相关文章推荐
- casperjs模拟登录-jd无验证码签到
- VC显示网页验证码、模拟CSDN网页登录
- 用wininet库模拟cookie方式验证码登录
- 在Python中用Request库模拟登录(三):Discuz论坛(未加密,有验证码,有隐藏验证)
- [PHP自动化-进阶]002.CURL模拟登录带有验证码的网站
- 使用PHP-curl获取验证码并模拟登录教务系统
- VC显示网页验证码、模拟CSDN网页登录
- 关于Android与HTTP模拟验证码登录爬坑之旅
- PHP curl模拟登录带验证码的网站
- PHP使用CURL实现对带有验证码的网站进行模拟登录的方法
- Python爬虫:模拟登录带验证码网站
- C# 利用 HttpWebRequest 和 HttpWebResponse 模拟登录有验证码的网站
- Java豆瓣电影爬虫——模拟登录的前世今生与验证码的爱恨情仇
- JD模拟用户登录(保持session)
- java 模拟登录含验证码
- Python模拟登录验证码(代码简单)
- 用casperjs模拟登录,支持多个账户登录
- 新浪微博模拟登录分析(含验证码)
- Jsoup模拟登录带验证码的教务系统(原理详解)
- -Java 模拟登录时需要输入验证码功能