我在想,如果我訪問使用Python的機制保護網站的密碼,我會得到它需要認證數據401未授權錯誤。如何使用python訪問受密碼保護的站點?
所以我的劇本里,我試圖訪問我的雅虎郵箱,這顯然需要用戶名和密碼,我想我會得到401,但我沒有。
代碼:
yahoo_mail = 'http://mail.cn.yahoo.com'
br = mechanize.Browser()
r = br.open(yahoo_mail)
print r.info() #here, I got 200, it's ok apparently
br.select_form(nr=0) #select the login form
r = br.submit() #submit the form without providing username and password
print r.info() #but I didn't get 401, why?
問:
- 爲什麼我沒有拿到401無需提供身份驗證,信息?
- 如果不是我的信箱,其他任何網站可以給我一個401?
我想你的意思是401未經授權,而不是410飄 – greg0ire