将 aiohttp 的异步 get 封装了 3 个函数。包含失败重试、串行任务、并行任务、随机延迟、任务并发数控制等特性
Project description
aiofetcher
将 aiohttp 的异步 get 封装了 3 个函数。包含失败重试、串行任务、并行任务、随机延迟、任务并发数控制等特性
示例
- 单个任务
import asyncio
from lzhaiofetcher import AioFetcher
async def main():
fetcher = AioFetcher()
html = await fetcher.fetch('http://example.com')
if html:
print(html[:200])
await fetcher.close()
asyncio.run(main())
- 多个任务,顺序做
import asyncio
from lzhaiofetcher import AioFetcher
async def main():
fetcher = AioFetcher()
urls = ["https://example.com", "https://another.com"]
results = await fetcher.fetch_all(urls)
await fetcher.close()
asyncio.run(main())
- 多个任务,同时做
import asyncio
from lzhaiofetcher import AioFetcher
async def main():
fetcher = AioFetcher(max_connections=20, concurrent_tasks=5)
urls = ["https://example.com", "https://another.com", "https://something.com"]
results = await fetcher.fetch_all_concurrent(urls)
await fetcher.close()
asyncio.run(main())
安装 - PyPI
pip install lzhaiofetcher
API
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lzhaiofetcher-1.1.tar.gz
(3.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lzhaiofetcher-1.1.tar.gz.
File metadata
- Download URL: lzhaiofetcher-1.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b966026cdd4ce1ebde69b8e82854592339bb7e1f30aa6856f8ff0cb5a61a8613
|
|
| MD5 |
dc4b716efc37ee708cb375de758f1a16
|
|
| BLAKE2b-256 |
a28c8e1ce307e14dd53377d4cb5affe8c532c242ae15bc4e4c06586ed24b61df
|
File details
Details for the file lzhaiofetcher-1.1-py3-none-any.whl.
File metadata
- Download URL: lzhaiofetcher-1.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a36d5674e0e44120973260d5eb9feb39e647dc5081c1337faa68a786b0ada3b
|
|
| MD5 |
3661cd6b18e5c1a15c888e536c0fefb4
|
|
| BLAKE2b-256 |
992f27f73516e1a089c26bc254089abc95f2119d6f25449bc65c622e16e26ded
|