urllib2 having trouble processing colon symbol in url

非 Y 不嫁゛ 提交于 2020-02-05 04:58:09


I am using the API for challonge and their url format is https://username:password@challonge.com/api/ However, when the use urllib2 in python to get this url, response = urllib2.urlopen('https://username:password@challonge.com/api/'), I get an error about a non-numerical port number. I believe this is cause by the colon (:) in the url making urllib2 think i'm trying to get a port of something. Is there anyway around this issue, or am I doing something wrong?


This is because you must use auth handlers like urllib2.HTTPBasicAuthHandler or other. urllib2 docs