2009-12-14 82 views
2

我想通過urllib獲取一些網址,並通過我的代理機械化。Python urllib代理

隨着機械化我嘗試以下方法:

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. 

作爲代理,用戶名和密碼是否正確,可能是什麼問題呢?

回答

0

也許代理正在使用NTLM身份驗證?

如果是這樣,您可以嘗試使用NTLM Authorization Proxy Server(另請參閱this answer)。

+0

感謝您的建議,我嘗試了http://code.google.com/p/python-ntlm/,仍然得到相同的錯誤 – pistacchio

+0

我不相信python-ntlm支持NTML代理(只有直接的HTTP連接)。你有沒有試過NTLM授權代理服務器? – codeape

+0

我試過了,它不是ntlm代理 – pistacchio

0

你可能會從響應頭

print br.response().info()

0

獲得更多的信息。當你的網絡瀏覽器使用代理服務器從本地 網絡中進行網上衝浪您可能會被要求驗證youself使用代理。 Google ntlmaps。