Proxy connection with Python

后端 未结 4 752
陌清茗
陌清茗 2021-01-06 01:06

I have been attempting to connect to URLs from python. I have tried: urllib2, urlib3, and requests. It is the same issue that i run up against in all cases. Once I get th

相关标签:
4条回答
  • 2021-01-06 01:39
    import requests
    proxies = {'https':'https://username:password@1.4.1.2:8080'}
    r = requests.get('http://www.example.com', proxies = proxies)
    print r.status_code, r.reason
    

    A working Solution! Tested on my server

    0 讨论(0)
  • 2021-01-06 01:43

    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
    
    0 讨论(0)
  • 2021-01-06 01:52

    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

    0 讨论(0)
  • 2021-01-06 01:54

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

    0 讨论(0)
提交回复
热议问题