Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theelous3/asks
Async requests-like httplib for python.
https://github.com/theelous3/asks
async async-requests concurrency curio http io network python3 requests trio
Last synced: 4 days ago
JSON representation
Async requests-like httplib for python.
- Host: GitHub
- URL: https://github.com/theelous3/asks
- Owner: theelous3
- License: mit
- Created: 2017-02-04T20:14:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-17T11:06:32.000Z (over 2 years ago)
- Last Synced: 2024-10-02T00:12:40.063Z (about 1 month ago)
- Topics: async, async-requests, concurrency, curio, http, io, network, python3, requests, trio
- Language: Python
- Size: 864 KB
- Stars: 508
- Watchers: 12
- Forks: 64
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-asyncio-cn - asks - 与 [requests](https://github.com/requests/requests) 接口相似的异步 HTTP 库。 (网络)
- starred-awesome - asks - Async requests-like httplib for python. (Python)
README
[![Build Status](https://travis-ci.org/theelous3/asks.svg?branch=master)](https://travis-ci.org/theelous3/asks) [![Docs Status](https://readthedocs.org/projects/asks/badge/?version=latest)](http://asks.readthedocs.io/en/latest/)
# asks
`asks` is an async `requests`-like HTTP lib, for use in conjunction with the wonderful [curio](https://github.com/dabeaz/curio) and [trio](https://github.com/python-trio/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!## Check the docs!
http://asks.readthedocs.io/
Above you'll find detailed docs with a large number of simple examples to help you get off the ground in no time.
## Installation
*Requires: Python 3.6.2 or newer.*
`pip install asks`
## Examples
```python
# one request
# A little silly to async one request, but not without its use!
import asks
import anyioasync def example():
r = await asks.get('https://example.org')
print(r.content)anyio.run(example)
``````python
# many requests
# make 1k api calls and store their response objects
# in a list.import asks
import triopath_list = ['http://fakeurl.org/get','http://example123.org']
results = []
async def grabber(s, path):
r = await s.get(path)
results.append(r)async def main(path_list):
from asks.sessions import Session
s = Session('https://example.org', connections=2)
async with trio.open_nursery() as n:
for path in path_list:
n.start_soon(grabber, s, path)trio.run(main, path_list)
```
#### Changelog
*2.0.0* - Setting `stream=True` means that the response returned will be a `StreamResponse` object rather than the default `Response` object.
##### Shoutout to ##lp, and the fine peeps of 8banana