Proxies with Python 'Requests' module

后端 未结 10 915
傲寒
傲寒 2020-11-22 12:13

Just a short, simple one about the excellent Requests module for Python.

I can\'t seem to find in the documentation what the variable \'proxies\' should contain. Whe

10条回答
  •  一向
    一向 (楼主)
    2020-11-22 12:18

    I have found that urllib has some really good code to pick up the system's proxy settings and they happen to be in the correct form to use directly. You can use this like:

    import urllib
    
    ...
    r = requests.get('http://example.org', proxies=urllib.request.getproxies())
    

    It works really well and urllib knows about getting Mac OS X and Windows settings as well.

提交回复
热议问题