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 and 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.2 or newer.
pip install asks
# one request# A little silly to async one request, but not without its use!importasksimportcurioasyncdefexample():
r=awaitasks.get('https://example.org')
print(r.content)
curio.run(example())# many requests# make 1k api calls and store their response objects# in a list.importasksimporttriopath_list= ['http://fakeurl.org/get','http://example123.org']
results= []
asyncdefgrabber(s, path):
r=awaits.get(path)
results.append(r)
asyncdefmain(path_list):
fromasks.sessionsimportSessions=Session('https://example.org', connections=2)
asyncwithtrio.open_nursery() asn:
forpathinpath_list:
n.start_soon(grabber, s, path)
trio.run(main, path_list)2.0.0 - Setting stream=True means that the response returned will be a StreamResponse object rather than the default Response object.