urllib2 having trouble processing colon symbol in url
Question:
I am using the API for challonge and their url format is https://username:[email protected]/api/
.
However, when I use urllib2 in python to get this url
response = urllib2.urlopen('https://username:[email protected]/api/')
I get an error about a non-numerical port number. I believe this is caused 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?
Answers:
This is because you must use auth handlers like urllib2.HTTPBasicAuthHandler or other.
urllib2 docs
I am using the API for challonge and their url format is https://username:[email protected]/api/
.
However, when I use urllib2 in python to get this url
response = urllib2.urlopen('https://username:[email protected]/api/')
I get an error about a non-numerical port number. I believe this is caused 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