asks is an async requests-like http lib, for use in conjunction with the wonderful curio and trio async libs.
asks aims to have a mostly familiar API, using simple functions/methods like get()
for getting, post()
for posting. At the heart of asks is a session class which makes interacting with the web in a sustained and fluid way fast, efficient, and simple. Check out the examples!
Above you'll find detailed docs with a large number of simple examples to help you get off the ground in no time.
Requires: Python 3.5.
pip install asks
Note: Currently supports trio's development branch. You can install this by doing pip install git+https://github.com/python-trio/trio.git
# one request
# A little silly to async one request, but not without its use!
import asks
import curio
asks.init('curio')
async def example():
r = await asks.get('https://example.org')
print(r.content)
curio.run(example())
# many requests
# make 1k api calls and store their response objects
# in a list.
import asks
import trio
asks.init('trio')
path_list = ['a', 'list', 'of', '1000', 'paths']
results = []
async def grabber(path):
r = await s.get(path)
results.append(r)
async def main(path_list):
async with trio.open_nursery() as n:
for path in path_list:
n.spawn(grabber(path))
s = asks.Session()
trio.run(main, path_list)