Using CookieJar in Python to log in to a website from "Google App Engine". What's wrong here?
Posted
by brilliant
on Stack Overflow
See other posts from Stack Overflow
or by brilliant
Published on 2010-04-03T10:47:26Z
Indexed on
2010/04/03
10:53 UTC
Read the original article
Hit count: 241
Hello everybody,
I've been trying to find a python code that would log in to my mail box on yahoo.com from "Google App Engine" . Here (click here to see that page) I was given this code:
import urllib, urllib2, cookielib
url = "https://login.yahoo.com/config/login?"
form_data = {'login' : 'my-login-here', 'passwd' : 'my-password-here'}
jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
form_data = urllib.urlencode(form_data)
# data returned from this pages contains redirection
resp = opener.open(url, form_data)
# yahoo redirects to http://my.yahoo.com, so lets go there instead
resp = opener.open('http://mail.yahoo.com')
print resp.read()
The author of this script looked into HTML script of yahoo log-in form and came up with this script.
That log-in form contains two fields, one for users' Yahoo! ID and another one is for users' password. Here is how HTML code of that page for both of those fields looks like:
User ID field:
<input type="text" maxlength="96" class="yreg_ipt" size="17" value="" id="username" name="login">
Password field:
<input type="password" maxlength="64" class="yreg_ipt" size="17" value="" id="passwd" name="passwd">
However, when I uploaded this code to Google App Engine I discovered that this log-in form keeps coming back to me, which, I assume, means that logging-in process didn't succeed. Why is it so?
© Stack Overflow or respective owner