script to Login a website

This is the place for queries that don't fit in any of the other categories.

script to Login a website

Postby wachkama » Wed Jul 31, 2013 2:51 pm

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 ?

Code: Select all
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()
Last edited by micseydel on Thu Aug 01, 2013 9:37 pm, edited 1 time in total.
Reason: Locked OP.
Posts: 1
Joined: Mon Jul 29, 2013 6:23 pm

Re: script to Login a website

Postby Kebap » Thu Aug 01, 2013 12:41 pm

Hi wachkama, welcome to the forums!
For this kind of problem, I can absolutely recommend you try out the faboulos debug command that is called "print".
Just print everything and see if it really shows what you would expect it to, and where it starts to go wrong.
Did you open the files correctly, can python actually read them, do you find any users, do you find passwords, etc.
For example, I assume, something may go wrong with your open() and seek(), because I see no read().
Then again, I am no python pro and just guessing, so I myself would also use "print" to confirm my assumption.
Last edited by micseydel on Thu Aug 01, 2013 9:37 pm, edited 1 time in total.
Reason: Removed quote after locking OP. (Thanks though Kebap.)
Due to the reasons discussed here we are moving to on October 1, 2016.

This forum will be closed. Please create an account at the new site to continue discussion.

Posts: 689
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 7 guests