How to use proxies with an HTTP session using the Python requests package

Here's a quick code sample:

import requests

proxies = {
'http': 'http://user:[email protected]:3128',
'https': 'http://user:[email protected]:3128',

# Create the session and set the proxies.
s = requests.Session()
s.proxies = proxies

# Make the HTTP request through the session.
r = s.get('')

# Check if the proxy was indeed used (the text should contain the proxy IP).
complete at 0.1614 s; cached: 1; cache enable: truek0fc32e467df5eeb89f300220322450c3448c1a5a.html