Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51729

Re: script to Login a website

From Dave Angel <davea@davea.name>
Subject Re: script to Login a website
Date 2013-08-01 12:59 +0000
References <ece5f6b0-16da-4c3a-83d1-6340cb10cb9d@googlegroups.com> <ktbdj7$im2$1@reader1.panix.com> <0bf56e63-a6d3-4c7a-a4e9-642351081311@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.76.1375362009.1251.python-list@python.org> (permalink)

Show all headers | View raw


wachkama@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

script to Login a website wachkama@gmail.com - 2013-07-31 08:33 -0700
  Re: script to Login a website John Gordon <gordon@panix.com> - 2013-07-31 16:21 +0000
    Re: script to Login a website wachkama@gmail.com - 2013-07-31 09:50 -0700
      Re: script to Login a website Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-31 22:57 -0400
      Re: script to Login a website Dave Angel <davea@davea.name> - 2013-08-01 12:59 +0000
  Re: script to Login a website Joel Goldstick <joel.goldstick@gmail.com> - 2013-07-31 16:39 -0400
  Re: script to Login a website wachkama@gmail.com - 2013-08-01 06:48 -0700
    Re: script to Login a website Dave Angel <davea@davea.name> - 2013-08-01 14:18 +0000
  Re: script to Login a website wachkama@gmail.com - 2013-08-01 12:31 -0700

csiph-web