Это скрипт Phantomjs, который я использовал в течение многих лет для входа в свою учетную запись Ebay:
var steps=[];
var testindex = 0;
var loadInProgress = false; //This is set to true when a page is still loading
/*********SETTINGS*********************/
var webPage = require('webpage');
var page = webPage.create();
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36';
page.settings.javascriptEnabled = true;
page.settings.loadImages = false; //Script is much faster with this field set to false
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
var system = require('system');
var args = system.args;
var cookiesFile = args[1];
/*********SETTINGS END*****************/
/**********DEFINE STEPS THAT PHANTOM SHOULD DO***********************/
steps = [
function(){
page.open("https://signin.ebay.it/ws/eBayISAPI.dll?SignIn", function(status){});
},
function(){
page.evaluate(function(){
document.getElementById("userid").value="myusername";
document.getElementById("pass").value="myebaypass";
document.getElementById("sgnBt").click();
});
},
function(){
var fs = require('fs');
fs.write(cookiesFile, phantomJsCookiesToNetScapeString(phantom.cookies), 'w');
var result = page.evaluate(function() {
return document.querySelectorAll("html")[0].outerHTML;
});
fs.write('/tmp/EbayLoggedIn.html',result,'w');
},
];
/**********END STEPS THAT PHANTOM SHOULD DO***********************/
//Execute steps one by one
interval = setInterval(executeRequestsStepByStep,1000);
function executeRequestsStepByStep(){
if (loadInProgress == false && typeof steps[testindex] == "function") {
steps[testindex]();
testindex++;
}
if (typeof steps[testindex] != "function") {
phantom.exit();
}
}
/**
* These listeners are very important in order to phantom work properly.
* Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded.
* Without this, we will get content of the page, even a page is not fully loaded.
*/
page.onLoadStarted = function() {
loadInProgress = true;
};
page.onLoadFinished = function() {
loadInProgress = false;
};
var phantomJsCookiesToNetScapeString = function(cookies) {
var string = "";
string += "# Netscape HTTP Cookie File\n";
string += "# http://curl.haxx.se/rfc/cookie_spec.html\n";
for(var i=0; i<cookies.length; i++) {
cookie = cookies[i];
string += cookie.domain + "\t" +
'TRUE' + "\t" +
cookie.path + "\t" +
cookie.secure.toString().toUpperCase() + "\t" +
((cookie.expiry != undefined) ? cookie.expiry : "") + "\t" +
cookie.name + "\t" +
cookie.value + ((i==cookies.length-1) ? "" : "\n");
}
return string;
};
Однако с сегодняшнего утра я обнаружил, что на целевой странице есть контрольный вызовподтвердите мою личность.
Вопрос в том, что я никогда не видел этот шаг проверки при входе через обычные браузеры (Firefox и Chrome, оба пробовали в режиме Private / Incognito), поэтому есть способ предотвратить Ebay отНасколько я пытаюсь войти в систему, используя Phantomjs?