casperjs類比登入-jd無驗證碼簽到

來源:互聯網
上載者:User

標籤:casperjs類比登入-jd無驗證碼簽到

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(‘http://vip.jd.com/‘);casper.then(function(){this.wait(5000,function() {          this.echo("I‘ve waited for 5 seconds again");     });});//可刪除casper.then(function() {      this.capture("vipjdcom1.jpeg");  });casper.then(function(){if (this.exists("#ttbar-login")) {this.click("#shortcut-2014 .w .fr #ttbar-login a");}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("accountloginui1.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("accountloginui2.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‘:‘[email protected]‘,‘nloginpwd‘:‘dys19871119‘,},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("vipjdcom2.jpeg");  });casper.then(function() {       this.click(".side-shortcut #checkinBtn .icon-set");}); casper.then(function() {      this.wait(2000,function() {          this.echo("I‘ve waited for 2 seconds again");     });  });casper.then(function() {      this.capture("vipjdcom3.jpeg");  });casper.then(function() {      this.echo("簽到成功");});casper.run();


本文出自 “素顏” 部落格,請務必保留此出處http://suyanzhu.blog.51cto.com/8050189/1900600

casperjs類比登入-jd無驗證碼簽到

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.