Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67530 > unrolled thread
| Started by | Marcus <marcuscvj@gmail.com> |
|---|---|
| First post | 2014-03-03 04:32 -0800 |
| Last post | 2014-03-03 08:47 -0500 |
| Articles | 9 — 3 participants |
Back to article view | Back to comp.lang.python
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
| From | Marcus <marcuscvj@gmail.com> |
|---|---|
| Date | 2014-03-03 04:32 -0800 |
| Subject | Iterate through a list and try log in to a website with urllib and re |
| Message-ID | <fc7c1c7d-7811-4e58-a999-1f2e9b297cd3@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | Marcus <marcuscvj@gmail.com> |
|---|---|
| Date | 2014-03-03 04:35 -0800 |
| Message-ID | <1177d930-a3c4-4152-818c-33d5172083f8@googlegroups.com> |
| In reply to | #67530 |
This is the code right now: http://pastebin.com/pE1YZX2K
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-03 23:44 +1100 |
| Message-ID | <mailman.7634.1393850675.18130.python-list@python.org> |
| In reply to | #67531 |
On Mon, Mar 3, 2014 at 11:44 PM, Chris Angelico <rosuav@gmail.com> wrote: > So basically, you're doing a dictionary attack. May I ask why you're > doing this, exactly?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-03 23:45 +1100 |
| Message-ID | <mailman.7635.1393850747.18130.python-list@python.org> |
| In reply to | #67531 |
On Mon, Mar 3, 2014 at 11:44 PM, Chris Angelico <rosuav@gmail.com> wrote: > So basically, you're doing a dictionary attack. May I ask why you're > doing this, exactly? oops, misclicked. I note that the user name 'alex' does not appear to match your name. I'm going to want a good reason for this code to be written, else you're on your own - I don't intend to help you steal someone else's password. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marcus <marcuscvj@gmail.com> |
|---|---|
| Date | 2014-03-03 04:51 -0800 |
| Message-ID | <d276dd23-f611-4665-8fc3-569f2a855d9e@googlegroups.com> |
| In reply to | #67533 |
Yes, it's only for my own use on my local WordPress installation. Only educational use.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-04 00:00 +1100 |
| Message-ID | <mailman.7637.1393851620.18130.python-list@python.org> |
| In reply to | #67534 |
On Mon, Mar 3, 2014 at 11:51 PM, Marcus <marcuscvj@gmail.com> wrote: > Yes, it's only for my own use on my local WordPress installation. Only educational use. What are you trying to learn, exactly? How to break into a WP site? Still dubious. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marcus <marcuscvj@gmail.com> |
|---|---|
| Date | 2014-03-03 05:05 -0800 |
| Message-ID | <948ed27b-e9ec-4062-97d7-2b4b0bb05672@googlegroups.com> |
| In reply to | #67536 |
It's not that hard to find a program that does this already. But I'm trying to learn how to use these modules to create this. I've started it and now i want to complete it so I can create another program and learn more about other stuff, maybe a Twitter script or something. How do I learn when not practice?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-03 23:44 +1100 |
| Message-ID | <mailman.7636.1393851089.18130.python-list@python.org> |
| In reply to | #67531 |
On Mon, Mar 3, 2014 at 11:35 PM, Marcus <marcuscvj@gmail.com> wrote: > This is the code right now: http://pastebin.com/pE1YZX2K That looks short enough to include in-line, no need to point us to an external site :) So basically, you're doing a dictionary attack. May I ask why you're doing this, exactly? ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2014-03-03 08:47 -0500 |
| Message-ID | <roy-435B9C.08471603032014@news.panix.com> |
| In reply to | #67530 |
In article <fc7c1c7d-7811-4e58-a999-1f2e9b297cd3@googlegroups.com>,
Marcus <marcuscvj@gmail.com> wrote:
> I'm trying to use urllib and urllib2 to open an url + login_data in a for
> loop.
Step 1: Ignore all that crap and get http://www.python-requests.org/
> 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)
In the ideal case, whatever you're talking to will return a success or
failure indication in the HTTP status code.
Lacking that, it will at least return something intended to be parsed
(like JSON).
Lacking that (and, unfortunately, common), you're reduced to
screen-scraping. But, if you've got to do that, at least use a tool
like lxml or BeautifulSoup to parse the HTML.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web