I recently tried to login into a webiste that forces me to accept cookies. I'm using phantomJs and casperJs. I wrote a little script that should handle the login, but it redirects me to a site that tells me I have to accept cookies. Email and password are just placeholders.
The site I want to login is https://de.buyvip.com/
. But I need to click the button Anmelden mit Amazon
so I can login with my amazon account. The other login form does not work. (That leads to this long url, I just copied it from my browser)
Can someone help me?
Here is the script:
var casper = require("casper").create()
var fs = require('fs');
var page = "https://www.amazon.de/ap/signin?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&pageId=quarterdeckde&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&clientContext=280-1158662-4507036&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&marketPlaceId=A38GABX06X24K&openid.assoc_handle=quarterdeckde&openid.return_to=https%3A%2F%2Fde.buyvip.com%2Fsignin&openid.pape.max_auth_age=0&siteState=http%3A%2F%2Fde.buyvip.com%2Fhomepage%3Fhash%3DM";
phantom.cookiesEnabled = true;
casper.start(page, function()
{
console.log("started");
this.fill('form#ap_signin_form', {
'email' : 'myMail',
'password' : 'myPass'
}, true);
});
casper.then(function()
{
fs.write("test.html", this.getHTML(), "w");
});
casper.run();
Maybe a bit later, but this is the answer:
casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
the cookies are failing because amazon doesn't like the default casper's user agent, in my case: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) CasperJS/1.0.2+Phantomjs/1.7.0 Safari/534.34"