I have written a python script that should log me in to a website. For the time 
being I want to login to gmail.com. My script pulls up the gmail webpage but 
does not input the login id and the password in the fields and  does not log me 
in. I assume I am missing on something in my script. Can some body have a look 
as to what I am missing on.

import cookielib
import urllib
import urllib2
import httplib

if __name__ == '__main__':
    urlLogin = 'http://www.gmail.com'

    id    = 'u2'
    passw = 'p2'

    fieldId   = 'Email'
    fieldPass = 'passwd'
    
    cj = cookielib.CookieJar()
    data = urllib.urlencode({fieldId:id, fieldPass:passw})

    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

    urllib2.install_opener(opener)

    usock = opener.open(urlLogin)
    usock = opener.open(urlLogin,  data)

    pageSource = usock.read()
    usock.close()
    print(pageSource)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to