【发布时间】:2011-11-29 08:45:19
【问题描述】:
我在想,如果我使用 python 的机制访问受密码保护的站点,我会得到一个需要身份验证数据的 401 Unauthorized 错误。
所以在我的脚本中,我尝试访问显然需要用户名和密码的雅虎邮箱,我以为我会得到 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?
问题:
- 为什么我没有提供 auth-info 就没有得到 401?
- 如果不是我的邮箱,其他网站可以给我一个 401 吗?
【问题讨论】:
-
我认为你的意思是 401 Unauthorized,而不是 410 Gone
标签: python authentication mechanize