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


Groups > comp.lang.python > #67530

Iterate through a list and try log in to a website with urllib and re

Newsgroups comp.lang.python
Date 2014-03-03 04:32 -0800
Message-ID <fc7c1c7d-7811-4e58-a999-1f2e9b297cd3@googlegroups.com> (permalink)
Subject Iterate through a list and try log in to a website with urllib and re
From Marcus <marcuscvj@gmail.com>

Show all headers | View raw


Hello,

I'm trying to use urllib and urllib2 to open an url + login_data in a for loop. How can I display when successfully logged in and how to show when the login is denied? 

I've tried use this:

html_content = urllib2.urlopen(url).read()
re.findall('ERROR: The password you entered for the username USER is incorrect.', html_content)

1. I want to try an if statement in a for loop
2. Iterate through a list and when the first password in the list is denied. It shall continue with the next password in the list and try that one.
3. When it's successfully logged in the program will stop the loop and print out the password that matches.

I'm stuck and need some help creating this.

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


Thread

Iterate through a list and try log in to a website with urllib and re Marcus <marcuscvj@gmail.com> - 2014-03-03 04:32 -0800
  Re: Iterate through a list and try log in to a website with urllib and re Marcus <marcuscvj@gmail.com> - 2014-03-03 04:35 -0800
    Re: Iterate through a list and try log in to a website with urllib and re Chris Angelico <rosuav@gmail.com> - 2014-03-03 23:44 +1100
    Re: Iterate through a list and try log in to a website with urllib and re Chris Angelico <rosuav@gmail.com> - 2014-03-03 23:45 +1100
      Re: Iterate through a list and try log in to a website with urllib and re Marcus <marcuscvj@gmail.com> - 2014-03-03 04:51 -0800
        Re: Iterate through a list and try log in to a website with urllib and re Chris Angelico <rosuav@gmail.com> - 2014-03-04 00:00 +1100
          Re: Iterate through a list and try log in to a website with urllib and re Marcus <marcuscvj@gmail.com> - 2014-03-03 05:05 -0800
    Re: Iterate through a list and try log in to a website with urllib and re Chris Angelico <rosuav@gmail.com> - 2014-03-03 23:44 +1100
  Re: Iterate through a list and try log in to a website with urllib and re Roy Smith <roy@panix.com> - 2014-03-03 08:47 -0500

csiph-web