Looks like plain login is impossible, i have tried with phantom/casperjs and - doesn't work.
Only works with Cookie (and works perfectly).
/*********SETTINGS*********************/
var page = require('webpage').create({viewportSize:{width: 1600,height: 900},
settings:{userAgent:'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',
javascriptEnabled:'true',
loadImages:'false'
}}), fs = require('fs');
/*********SETTINGS END*****************/
console.log('All settings loaded, start with execution');
page.onLoadStarted = function() { console.log('Loading started') };
page.onLoadFinished =function() { console.log('Loading finished') };
page.onConsoleMessage = function(msg) { console.log(msg) };
// in these vars, you need to have the values of your cookies:
var at_main='Atza|IwEBIDds270mDqc9pBDWo49OWmIG2UAKXp8N3eYPzCuYn3fFGojBcZXag7M3uZdGurgA28cZA49zToQaoJ0DkQ8ZiAzu6EypTNzrskJNRp-IBqmKPh78s4oSU7o5oBv-7sgmjT-E8_pyxS0oC-t0SYAXdjSYzUeJbXUTTdweOVj_astxNj6_H1uqWysZw59G6sYkwq3A5JhCN_NVZszHUpmQvU4JrhAzV5a8vZgAJmFG5lnK8xl3Nk3uZNTVG3pQYhQ_SLPirg9cdDWICCQFO-fljcnad4PoPRQqdPsUw6OpCHrXEmkEDhn0EC49RzSA63bFlUKTAUUfREuiv0EXoobi19l4Ae98cq_qz38CA4UKF4OHWyBDpAZwZtgUANlaj_l82xUbWwR6yUgZByB-7jICsIs0',
sess_at_main='RDK4Kzj6ywmJnwhNdqkc37bjioL/FEX20dcHnjMMMUk=',
session_id='166-7700254-1158037',
ubid_main='157-9343046-5202510',
x_main='DBSZwuolSC12SSlS36cN7VhwXIg770zKumtGLK9THJji?XszMxT4xe?0FNT@MMfQ';
phantom.cookies = [{// an array of objects
'name' : 'at-main',
'value' : at_main,
'domain' : '.amazon.com',
'path' : '/',
'httponly' : false,
'secure' : true,
'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) }, //5 years // end of 1
{ 'name' : 'sess-at-main',
'value' : sess_at_main,
'domain' : '.amazon.com',
'path' : '/',
'httponly' : false,
'secure' : true,
'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) }, // end of 2
{ 'name' : 'session-id',
'value' : session_id,
'domain' : '.amazon.com',
'path' : '/',
'httponly' : false,
'secure' : true,
'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) }, // end of 3
{ 'name' : 'ubid-main',
'value' : ubid_main,
'domain' : '.amazon.com',
'path' : '/',
'httponly' : false,
'secure' : true,
'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) }, // end of 4
{ 'name' : 'x-main',
'value' : x_main,
'domain' : '.amazon.com',
'path' : '/',
'httponly' : false,
'secure' : true,
'expires' : (new Date()).getTime() + (1000 * 60 * 60 * 43800) } // end of 5
]
//Execute steps one by one
page.open("https://developer.amazon.com/home.html", function(status){
console.log('Step 1');
page.render('step1.png');
setTimeout(step2,3000);
function step2(){
console.log("Step 2");
page.render('step2.png');
var result=page.evaluate(function(){return document.documentElement.outerHTML});
fs.write('AmazonLoggedIn.html',result,'w'); phantom.exit();
}
});
step1.png
// in these vars, you need to have the values of your cookies:
var at_main=' ',
sess_at_main=' ',
session_id=' ',
ubid_main=' ',
x_main=' ';
You probably also need to set the Keep me signed in
chekbox:
Update:
To avoid that hell with the login, you can use --cookies-file
option!
After the second attempt, your script works like a charm !!
./phantomjs --cookies-file=./cookies_2.txt am.js luxadm1@gmail.com pass >/dev/stdout