Proxy connection with Python

早过忘川 提交于 2019-11-30 22:32:30

In the requests module, proxy authentication is performed as shown:

import requests
proxies = {'http':'http://x.x.x.x', 'https':'https://x.x.x.x'}
auth = requests.auth.HTTPProxyAuth('username', 'password')
r = requests.get('http://www.example.com', proxies = proxies, auth = auth)
print r.status_code, r.reason

I have solved my issue by installing CNTLM. Once this is setup and configured I set the HTTP_PROXY etc.

You can use the HTTP_PROXY in python in order to connect to your proxy server. You can find more detailed information on this link provided.

http://www.wkoorts.com/wkblog/2008/10/27/python-proxy-client-connections-requiring-authentication-using-urllib2-proxyhandler/

The above link is showed the example using urllib2. Actually I have used this some time back to connect to two servers simultaneously. Hope this will help you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!