0
試圖登錄admin.booking.com
,並從預訂頁面中刪除我酒店的所有預訂。但事情是每當我使用CasperJS登錄或從一個新的位置(新瀏覽器)登錄時,它都會要求進行電話驗證。它將預訂頁面重定向到電話驗證頁面。這裏是我的代碼網站使用casperjs或新瀏覽器登錄時要求輸入驗證碼
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
viewportSize: {width: 950, height: 950}
});
casper.userAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36');
casper.start('https://admin.booking.com/', function() {
//this.captureSelector('bhuwan1.png', 'body');
});
casper.then(function(){
this.evaluate(function(){
document.getElementById("loginname").value="1123123";
document.getElementById("password").value="*******";
});
});
casper.then(function(){
//$("button").eq(1).click();
this.click('button.btn-primary');
//this.wait(10000);
console.log("first wait for 10sec");
});
casper.then(function(){
this.wait(10000);
});
casper.then(function(){
var ses = this.getCurrentUrl().split("ses=")[1].split("&")[0];
console.log(ses);
//this.wait(10000);
console.log("first wait for 10sec");
var url = "https://admin.booking.com/hotel/hoteladmin/extranet_ng/manage/search_reservations.html?stay_to=2017-01-08&stay_from=2017-01-07&type=arrival&hotel_id=xxxxx&ses="+ses;
console.log(url);
this.evaluate(function(url){
var newDiv = document.createElement("div");
var newContent = document.createElement("a");
newContent.setAttribute("href",url);
newContent.innerText="button";
newDiv.appendChild(newContent);
document.body.appendChild(newDiv);
this.wait(10000);
},url);
});
casper.then(function(){
this.clickLabel("button",'a');
});
casper.then(function(){
this.wait(10000);
console.log("first wait for 10sec");
this.capture('stack15.png', {
top: 0,
left: 0,
width:1000,
height: 2000
});
this.captureSelector('bhuwan15.png', 'body');
});
casper.run();
如何避免手機驗證頁面和登錄,如果充分利用熟悉的或舊的瀏覽器登錄?
如何使用的cookies文件選項是什麼my_file – Bhuwan
'--cookies文件= /路徑/到/ cookies.txt'指定用於存儲持久性Cookie的文件名。 PhantomJS - [命令行選項](http://phantomjs.org/api/command-line.html)。 我也覺得,它可能不需要,或者你可以嘗試它,而不設置'phantom.cookies'。 – 2017-05-27 13:00:12
沒有設置phatom.cookies它只是將所有的cookie傳輸到cookies.txt。謝謝 – Bhuwan