Curl requests for Humans
human_curl allow you to send HEAD, GET, POST, PUT, PATCH, and DELETE HTTP requests.
Simple get request
>>> import human_curl as requests # python-requests.org compatibile
>>> r = requests.get('http://h.wrttn.me/basic-auth/test_username/test_password', auth=('test_username', 'test_password'))
>>> r.status_code
200
>>> r.content
'{"username": "test_username", "password": "test_password", "authenticated": true}'
Send files and variables
>>> import human_curl as requests
>>> r = requests.post('http://h.wrttn.me/post', files=(('file_1', '/tmp/testfile1.txt'),
... ('file2', open('/tmp/testfile2.txt'))), data={'var_name': 'var_value'})
...
>>> r.status_code
201
Redirects
>>> import human_curl as requests
>>> r = requests.get('http://h.wrttn.me/redirect/4', allow_redirects=True)
>>> r.status_code
200
>>> print(r.history)
['http://h.wrttn.me/redirect/3', 'http://h.wrttn.me/redirect/2', 'http://h.wrttn.me/redirect/1', 'http://h.wrttn.me/redirect/end']
>>> print(r.url)
http://h.wrttn.me/redirect/end
To use human_curl use pip or easy_install:
pip install human_curl
or
easy_install human_curl
Fork https://github.com/Lispython/human_curl/ , create commit, create pull request.
Contents: