Skip to content

Instantly share code, notes, and snippets.

@wzpan
Created August 3, 2013 14:30
Show Gist options
  • Select an option

  • Save wzpan/6146665 to your computer and use it in GitHub Desktop.

Select an option

Save wzpan/6146665 to your computer and use it in GitHub Desktop.
Python - http web
# get
import httplib2
h = httplib2.Http('.cache')
response, content = h.request('http://diveintopython3.org/examples/feed.xml')
# post
from urllib.parse import urlencode
import httplib2
h = httplib2.Http('.cache')
data = {'status': 'Test update from Python 3'}
h.add_credentials('diveintomark', 'MY_SECRET_PASSWORD', 'identi.ca')
resp, content = h.request('https://identi.ca/api/statuses/update.xml',
'POST',
urlencode(data),
headers={'Content-Type': 'application/x-www-form-urlencoded'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment