Created
August 3, 2013 14:30
-
-
Save wzpan/6146665 to your computer and use it in GitHub Desktop.
Python - http web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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