Requests
http-библиотечка на python для запросов/ответов.
Пример
>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf8'
>>> r.encoding
'utf-8'
>>> r.text
'{"type":"User"...'
>>> r.json()
{'private_gists': 419, 'total_private_repos': 77, ...}
How to send request_body encoded as application/x-www-form-urlencoded
Это требуется, к примеру, при реализации bearer [http] схемы аутентификации
...
endpoint = "some url"
data={"username": f"{login}", "password": f"{password}"}
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
response = requests.post(endpoint, data=data, headers=headers)
print(response)
Смотри еще:
- [http-requests-errors]
- grequests GRequests allows you to use Requests with Gevent to make asynchronous HTTP Requests easily.
- requests-futures Asynchronous Python HTTP Requests for Human
- requests-threads This repo contains a Requests session that returns the amazing Twisted’s awaitable Deferreds instead of Response objects
- [aiohttp]