Proxies with Python 'Requests' module

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

    If you'd like to persisist cookies and session data, you'd best do it like this:

    import requests
    
    proxies = {
        'http': 'http://user:pass@10.10.1.0:3128',
        'https': 'https://user:pass@10.10.1.0:3128',
    }
    
    # Create the session and set the proxies.
    s = requests.Session()
    s.proxies = proxies
    
    # Make the HTTP request through the session.
    r = s.get('http://www.showmemyip.com/')
    

提交回复
热议问题