Include me in the list

nusrath ahmed nusrathahmed at
Sun Apr 24 16:34:46 EDT 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 = 

    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))


    usock =
    usock =,  data)

    pageSource =
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list