溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

casperjs模擬登錄-jd無驗證碼登錄

發布時間:2020-07-07 10:49:14 來源:網絡 閱讀:1756 作者:素顏豬 欄目:開發技術
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://cache.yisu.com/upload/information/20200312/65/243442");  
});

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();


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女