script to Login a website

wachkama at gmail.com wachkama at gmail.com
Thu Aug 1 09:48:22 EDT 2013


On Wednesday, July 31, 2013 11:33:25 AM UTC-4, wach... at gmail.com wrote:
> 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:
> 
>         password.seek(0)
> 
>         for pass_list in password:
> 
>             login_data = users + '\n' + pass_list
> 
>             print login_data
> 
>            
> 
>     base_url = 'http://mysite.com'       
> 
>     #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)
> 
>     response.read()
> 
>     print response.headers
> 
>     print response.getcode()


This is how my out put looks like when I run the script

User1 at mymail.com
Password1

User1 at mymail.com
Password2

User1 at mymail.com
Password3

User1 at mymail.com
Password4

User2 at mymail.com
Password1

User2 at mymail.com
Password2

User2 at mymail.com
Password3

User2 at mymail.com
Password4

User3 at mymail.com
Password1

User3 at mymail.com
Password2

User3 at mymail.com
Password3

User3 at mymail.com
Password4

User4 at mymail.com
Password1

User4 at mymail.com
Password2

User4 at mymail.com
Password3

User4 at mymail.com
Password4

Date: Thu, 01 Aug 2013 13:45:07 GMT
Server: Apache
X-Powered-By: PHP/5.3.3
Set-Cookie: PHPSESSID=3523t5l1vhqisaabfss8ra5tv5; path=/
Cache-Control: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

200





More information about the Python-list mailing list