urllib2基本身份验证是一个命中和错过

时间:2011-08-25 22:09:54

标签: urllib2 basic-authentication

我在urllib2中的身份验证有问题,它正在点击一些页面

像我一样

https://localhost:5260/user

我正在使用基本身份验证及其正常工作,正确检索页面

username = 'test'
password = 'test'
base64string = base64.encodestring('%s:%s' % (username, password))[:-1]
authheader =  "Basic %s" % base64string

但是当我将同一个东西应用到另一个用户是管理员并尝试访问的页面时,它不会返回带有身份验证的页面

https://localhost:5260/post/250

我理解这是保存状态的事情,但我无法弄明白。

1 个答案:

答案 0 :(得分:0)

现在这似乎微不足道了,我需要设置cookie并将该信息传递给服务器:)

下面的链接很好地描述了如何查看它。

http://www.voidspace.org.uk/python/articles/cookielib.shtml

相关问题