In article <fc7c1c7d-7811-4e58-a999-1f2e9b297...@googlegroups.com>,
 Marcus <marcus...@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.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to