using openurl to log into Yahoo services

Dan Sommers me at privacy.net
Wed Nov 16 06:29:40 EST 2005


On Tue, 15 Nov 2005 16:08:06 -0000,
"joe_public34" <joe_public34 at yahoo.com> wrote:

> Hello all,
> I'm trying to write a script to log into Yahoo! (mail, groups, etc),
> but when I pass the full URL with all form elements via Python, I get
> a resutling 400 - Bad Request page.  When I just plop the full URL
> into a browser, it works perfectly. Is there something I need to
> specify in python to submit the correct info (headers, user agent,
> etc) to get the response I want? Here is the code I have that returns
> the Bad Request:

> import urllib, win32gui, win32clipboard, win32con, os, getpass, re
> yid = raw_input("Yahoo! ID: ")
> pw = getpass.getpass(prompt = 'Yahoo password: ')
> url =
> "https://login.yahoo.com/config/login?.tries=1&.src=ygrp&.intl=us&.v=0&.challenge=U4VY1YGqdPf8z3SaVccJdhV63YCw&.chkP=Y&.done=http://groups.yahoo.com&login="+yid+"&passwd="+pw+"&.persistent=y&.save=Sign
> In"
> temp = urllib.urlopen(url)
> grp_list_source = temp.read()

> Any thoughts or suggestions?  Thanks.

It is possible that the "challenge" field is created by yahoo's server
based on the request that caused the server to serve the login page;
perhaps it contains a hash of the user agent that sent the request.
When you reply to that challenge at a much later time, or with a
different user agent, or with something else that's different from the
original request, yahoo's server thinks you're trying to break into
yahoo.

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>



More information about the Python-list mailing list