script to Login a website

wachkama at wachkama at
Wed Jul 31 17:33:25 CEST 2013

I have created a script to log in a website. It gets its username and password from two files, then log's in with this credentials. My code is not showing me what username it is using to login from the file. And I am not sure if it is even opening up the url and prompting for login. I am stuck can someone help me ?

    import urllib, urllib2

    user = open ('users.txt' , 'r')
    password = open ('password.txt' , 'r')

    for users in user:
        for pass_list in password:
            login_data = users + '\n' + pass_list
            print login_data
    base_url = ''       
    #login action we want to post data to 
    response = urllib2.Request(base_url)     
    login_action = '/auth/login'   
    login_action = base_url + login_action
    response = urllib2.urlopen(login_action, login_data)
    print response.headers
    print response.getcode()

More information about the Python-list mailing list