OK. requests does a little better. As I suspected, one must overcome a Javascript challenge. Here's the script for your delight:
(function(){
var a = function() {try{return !!window.addEventListener} catch(e) {return !1} },
b = function(b, c) {a() ? document.addEventListener("DOMContentLoaded", b, c) : document.attachEvent("onreadystatechange", b)};
b(function(){
var a = document.getElementById('cf-content');a.style.display = 'block';
setTimeout(function(){
var t,r,a,f, zxyHslq={"vRRShbXaOtY":!+[]+!![]+!![]+!![]+!![]+!![]};
t = document.createElement('div');
t.innerHTML="<a href='/'>x</a>";
t = t.firstChild.href;r = t.match(/https?:\/\//)[0];
t = t.substr(r.length); t = t.substr(0,t.length-1);
a = document.getElementById('jschl-answer');
f = document.getElementById('challenge-form');
;zxyHslq.vRRShbXaOtY*=+((+!![]+[])+(+!![]));zxyHslq.vRRShbXaOtY+=!+[]+!![]+!![]+!![]+!![]+!![];zxyHslq.vRRShbXaOtY+=!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![];zxyHslq.vRRShbXaOtY*=+((+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]));zxyHslq.vRRShbXaOtY+=+((!+[]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]));zxyHslq.vRRShbXaOtY+=!+[]+!![];zxyHslq.vRRShbXaOtY-=+((+!![]+[])+(!+[]+!![]));zxyHslq.vRRShbXaOtY+=+((!+[]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]));zxyHslq.vRRShbXaOtY*=+((!+[]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]));a.value = parseInt(zxyHslq.vRRShbXaOtY, 10) + t.length;
f.submit();
}, 5850);
}, false);
})();
That above is the challenge, of course.
I think I'll use an external javascript VM (maybe the one used for node.js?).
BTW, mechanize doesn't support Javascript! I think that, in general, no Python library does.
I'll need to handle Javascript myself. Either I build a simple specific interpreter for that kind of code, or I use an external Javascript VM. Even with a VM, I'll need to change the code a bit because a general VM doesn't understand browser related stuff.
Last edit:
I managed to do the entire procedure by hand in a Python REPL.
1) I get the javascript code and transform it so that it can run outside the browser.
2) I run the code in jsdb (a little interpreter) and read the result.
3) I send the answer to the site and receive two cookies which I must use for each future requests.
4) The rest is easy... It took me a while to realize that requests' automatic redirection messes things up.