clientcookie/clientform and checking to see if a website accepted my login details

John J. Lee jjlee at reportlab.com
Thu Mar 8 08:02:43 EST 2007


socialanxiety at gmail.com writes:

> alright, i'm coding a program that will log me into yahoo.com (so
> far), now, the problem i have is that once i've submitted by login &
> password, the program doesn't know whether yahoo.com accepted it.
> "
> response = ClientCookie.urlopen(form.click())
> "
> 
> now, when i get an error, the contents of 'response' will be
> different, ex: the contents of  '<title>example</title>' will be
> '<title>logged in!</title>'. is there any function that can search
> through the code for that text to check if i'm logged in or not?

There's no general way to find out (regardless of whether you're using
Python or something else).  So:

data = response.read()
logged_in = 'logged in!' in data
if logged_in:
    print "logged in OK"


John




More information about the Python-list mailing list