[英]HTTP Basic Auth Handler Error in Python
我試圖從python登錄到我的cPanel,但是我總是收到401訪問被拒絕的代碼錯誤。 我已經用谷歌搜索,嘗試過,但是沒有成功,這是登錄部分的代碼。
try:
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password("cPanel", site, base64.encodestring(user)[:-1], base64.encodestring(passwd)[:-1])
print site,base64.encodestring(user)[:-1],base64.encodestring(passwd)[:-1]
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
urllib2.urlopen(site)
except (urllib2.HTTPError, httplib.BadStatusLine), msg:
print msg
誰能指出我到底在做什么錯?
我傳遞的URL是https://mydomain.com:2083
為什么要對用戶名和密碼進行base64編碼? 身份驗證處理程序將為您完成此任務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.