我有一个经过身份验证的资源,需要域、用户名和密码进行身份验证。 Python的urllib2提供了realm,而我没有找到httplib2的任何规定。 下面是示例代码, 使用urllib2:
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password("Protected",
uri="http://" + url,
user=username,
passwd=password)
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
try :
data = urllib2.urlopen(url, None, timeout).read()
这里“Protected”是身份验证所需的领域。在
现在看看httplib2:
^{pr2}$对于httplib2,我没有找到任何提供域字符串进行身份验证的规定。在
有没有办法在httplib2中添加这个领域字符串??在
如果} 就变得微不足道了:
httplib2
不是必须的,那么使用^{相关问题 更多 >
编程相关推荐