- Notifications
You must be signed in to change notification settings - Fork63
Async requests-like httplib for python.
License
theelous3/asks
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
asks
is an asyncrequests
-like HTTP lib, for use in conjunction with the wonderfulcurio andtrio async libs.
asks
aims to have a mostly familiar API, using simple functions/methods likeget()
for getting andpost()
for posting.At the heart ofasks
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.6.2 or newer.
pip install asks
# one request# A little silly to async one request, but not without its use!importasksimportanyioasyncdefexample():r=awaitasks.get('https://example.org')print(r.content)anyio.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 - Settingstream=True
means that the response returned will be aStreamResponse
object rather than the defaultResponse
object.
About
Async requests-like httplib for python.