Python urllib 代理

2 投票
3 回答
3140 浏览
提问于 2025-04-15 16:59

我正在通过我的代理使用urllib和mechanize来获取一些网址。

在使用mechanize时,我尝试了以下代码:

from mechanize import Browser
import re

br = Browser()
br.set_proxies({"http": "MYUSERNAME:*******@itmalsproxy.italy.local:8080"})
br.open("http://www.example.com/")

但是我遇到了以下错误:

httperror_seek_wrapper: HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied.

由于代理的用户名和密码都是正确的,那可能是什么问题呢?

3 个回答

0

当你的网页浏览器通过代理服务器在本地网络上上网时,可能需要你先进行身份验证才能使用这个代理。你可以搜索一下“Google ntlmaps”来了解更多。

0

你可以从响应的头信息中获取更多信息。

print br.response().info()

0

可能这个代理在使用NTLM认证?

如果是这样的话,你可以试试这个NTLM授权代理服务器(还可以看看这个回答)。

撰写回答