Pls chk my login script

nusrath ahmed nusrathahmed at yahoo.com
Sun Apr 24 18:05:11 EDT 2011


I have written a python script for logging into a website. My script pulls up a 
browser page but does not log me in. Can any one suggest if I i am wrong in nay 
way,though the script is correct I am sure

My script is as below


*********************************************
import cookielib
import urllib
import urllib2
import httplib

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

    id    = 'u2'
    passw = 'p2'

    fieldId   = 'username'
    fieldPass = 'password'
    
    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)
    
    *************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110424/4af8fdeb/attachment.html>


More information about the Python-list mailing list