7/1/2015 - 8:58 AM

Python HTTP requests. http://docs.python-requests.org/en/latest/

import json
import requests

url = 'http://...'
r = requests.get(url)
html_s = r.text # content of the server’s response
json_data = json.loads(html_s)
json_data = r.json() # requests has its own json decoding
r.content # access the response body as bytes, for non-text requests

session = requests.Session() # persist certain parameters across requests (like cookies)
headers = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36'}
r = session.get('https://...', headers=headers)

# send some form-encoded data — much like an HTML form
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post("http://httpbin.org/post", data=payload)