Skip to main content

安装: pip install asyncpy

## Asynpy

Asynpy 是一个异步请求框架,基于asyncio和aiohttp,实现便捷高效的从网络上抓取数据

“With reference to the design pattern of scrapy, an asynchronous co-processing method is adopted to simplify some operations and complete the tasks of web crawler more easily and efficiently”

### asyncio asyncio是Python 3.4版本引入用来编写并发代码的标准库,直接内置了对异步IO的支持。 asyncio的编程模型就是一个单线程的消息循环。 从asyncio模块中直接获取一个EventLoop的引用,然后把需要执行的协程扔到EventLoop中执行,就实现了异步IO。

### aiohttp aiohttp - 基于asyncio实现的HTTP框架。 aiohttp强调的是异步并发。提供了对asyncio/await的支持,可以实现单线程并发IO操作。

#### 单线程的asyncio为什么速度会更快呢? - 多线程是基于系统的,协程是基于线程的,多线程上下文切换有陷入内核态的消耗,协程就没有,协程更轻量 - Python的GIL阻止两个线程在同一个程序中同时执行,有时候多线程并没有单线程速度快。 - 而Scrapy是基于twited的单线程框架,消息队列和事件循环在一个线程来回切换,downloader是多线程的

#### 详细操作文档请参考博客或者github:

https://blog.csdn.net/weixin_43582101/article/details/106258518

https://github.com/lixi5338619/asyncpy

Thanks : Scrapy、Ruia、Looter、asyncio、aiohttp

公众号《Pythonlx》

Metadata

Release files for asyncpy 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncpy 1.2.0
File Size Uploaded
asyncpy-1.2.0.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncpy 1.2.0
File Interpreter ABI Platform
asyncpy-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / asyncpy-1.2.0.tar.gz

Download URL asyncpy-1.2.0.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
761b891750243db84afc0f9c0de89d4ffb01f5786f2bde65d202522520c7933d
BLAKE2b-256 checksum
How to use checksums
74aebc3dd080b5ced473e787674974a74b3a2be9d4b9be582c991032fb2e7d11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.8

Release files / asyncpy-1.2.0-py3-none-any.whl

Download URL asyncpy-1.2.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad1cb2dc04abecb7591ee39092bbf8850b710cd2766b05ec9b714a6d28cb4484
BLAKE2b-256 checksum
How to use checksums
fa4242ac2211df840c2b405dc655739d1d4e46e38714622f5908a4966c10cb7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.8

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page