Include me in the list

nusrath ahmed nusrathahmed at yahoo.com
Sun Apr 24 22:34:46 CEST 2011


I have written a python script for logging into a website. For the  time being I 
have created a login page and a website which I want to log  in. My script pulls 
up the  login page but does not post the username  and password and log me in. 
It simple displays the login page. I wanted  my script to log me in also. Can 
some body please go through the script  and correct me/ help me login.

My script is as below


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

if __name__ == '__main__':
    urlLogin = 
'file:///C:/Documents%20and%20Settings/Fat/Desktop/New%20Folder/Login.html'

    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/0a16cc78/attachment.html>


More information about the Python-list mailing list