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?


回答1:


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



来源:https://stackoverflow.com/questions/9696999/urllib2-having-trouble-processing-colon-symbol-in-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!