Why does 'url' not work as a variable here?

Posted by kryptobs2000 on Stack Overflow See other posts from Stack Overflow or by kryptobs2000
Published on 2010-05-12T19:40:12Z Indexed on 2010/05/12 19:44 UTC
Read the original article Hit count: 158

Filed under:

I originally had the variable cpanel named url and the code would not return anything. Any idea why? It doesn't seem to be used by anything else, but there's gotta be something I'm overlooking.

import urllib2

cpanel = 'http://www.tas-tech.com/cpanel'
req = urllib2.Request(cpanel)
try:
    handle = urllib2.urlopen(req)
except IOError, e:
    if hasattr(e, 'code'):
        if e.code != 401:
            print 'We got another error'
            print e.code
        else:
            print e.headers
            print e.headers['www-authenticate']

© Stack Overflow or respective owner

Related posts about python