机械化中出现'407 Proxy Authentication requires'错误


import mechanize
b=mechanize.Browser()
b.set_handle_robots(False)
b.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
b.open("http://www.google.co.in")
b.select_form(nr=0)
b['q']='alpha'
b.submit()
x=b.response()
print x.read()

以上代码正常工作。但是,当我将http更改为https时,我得到"407代理身份验证需要"错误。这背后的原因是什么?如何解决这个问题?另外,设置了http_proxyhttps_proxy环境变量,并且我在Linux机器上。

一些应用程序对环境变量是大小写敏感的,所以最好在/etc/environment文件中以以下方式设置所有环境变量:

http_proxy=http://username:password@host:port_no
https_proxy=https://username:password@host:port_no
HTTP_PROXY=http://username:password@host:port_no
HTTPS_PROXY=https://username:password@host:port_no

请记住在用户名之前设置协议

最新更新