Proxies with Python 'Requests' module

后端 未结 10 819
傲寒
傲寒 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:30

    You can refer to the proxy documentation here.

    If you need to use a proxy, you can configure individual requests with the proxies argument to any request method:

    import requests
    
    proxies = {
      "http": "http://10.10.1.10:3128",
      "https": "https://10.10.1.10:1080",
    }
    
    requests.get("http://example.org", proxies=proxies)
    

    To use HTTP Basic Auth with your proxy, use the http://user:password@host.com/ syntax:

    proxies = {
        "http": "http://user:pass@10.10.1.10:3128/"
    }
    

提交回复
热议问题