script to Login a website

Dave Angel davea at davea.name
Thu Aug 1 08:59:41 EDT 2013


wachkama at gmail.com wrote:

> On Wednesday, July 31, 2013 12:21:59 PM UTC-4, John Gordon wrote:

     <SNIP lots of double-spaced stuff>
>> 
>> How is the data in 'users.txt' and 'password.txt' organized?  Given the
>> 
>> filenames, I would expect that 'users.txt' contains one username on each
>> 
>> line, and 'password.txt' contains one password on each line, with the
>> 
>> first username belonging with the first password, the second username
>> 
>> belonging with the second password, and so on.
>> 
     <SNIP lots more>

> the user.txt file has one user name on each line and so does the password.txt. with this in mind each user will attempt to log in with all the passwords on password.txt file. when it gets to the end of the line it will go to the next user in users.txt and do the same i.e attempt to log in with all the passwords in the file.
> So to your second question I will use all the users one after the other attempting to log in.
> I am able to get each user to use "x" number of passwords in the password.txt that part works fine. The login section is where I am stuck ?

My guess is you've got a nested loop, with the outer loop going through
the user file, and the inner loop going through the password file.

You're attempting to do readline() or equivalent from the password
file in the inner loop, and once you've gone through the outer loop
once, there is nothing left in the password file.

userfile = open("user.txt")
passwordfile = open("password.txt")

for user in  userfile:
      for password in passwordfile:
            process this user/pw combination


If that's your logic, simply move the open line for password.txt into
the outer loop, so it gets reopened each time.

You could also do a seek() to get to the beginning of the file each
time, or you could preread all the passwords into a list, or ...

Please note that the buggy googlegroups has totally messed up your
quoting.  Either restrict the quoting to a couple of lines, or remove
all those extra blank lines.

-- 
DaveA




More information about the Python-list mailing list