AioFastGet-0.0.7
توضیحات
AsyncioFastGetFrame
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | AioFastGet-0.0.7 |
| نام | AioFastGet |
| نسخه کتابخانه | 0.0.7 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | dalyer |
| ایمیل نویسنده | 954742660@qq.com |
| آدرس صفحه اصلی | https://github.com/me/myproject |
| آدرس اینترنتی | https://pypi.org/project/AioFastGet/ |
| مجوز | MIT |
01、Installation
-----
```bash
pip install AioFastGet
```
## 02、Notice
> 后期如何使用?
> 1:默认redis 库是 aioredis==1.3.1 要安装这个版本的异步redis
> 2:
> (1)继承这个类,
> (2)然后将url通过_addurl 添加进来
> (3)写一个接受返回结果的async函数
> (4)启动crawl_main方法
> 3:可以更改参数
> 指定redis_key/redis_db/_max_workers/_poptype = 'FIFO' ##先进先出
## 03、Eexmple
```python
from AioFastGet import RedisUrlPool
import asyncio
class GetFast(RedisUrlPool):
def __init__(self):
super(GetFast,self).__init__(host="192.168.100.79", db=0, password="abcde", port=6381)
self._redisKey = "BaiduList" ##指定网络池的key
self._max_workers = 2 ##开始多少个任务
async def load_url(self):
"""加载url item"""
for i in range(10):
# 访问http://www.httpbin.org/delay/2 是需要2秒才能返回内容。
# 我们可以加载十个请求链接,按传统的方式是大概需要20多秒才能完成这10个请求
# 可以自己拿起手表计算下,我们访问了10个请求花了多长的时间
url_item = {"url":"http://www.httpbin.org/delay/2","backfunc":"parse_baidu"}
await self._addurl(url_item)
async def parse_baidu(self,r):
"""解析对应的回调函数"""
print(r.keys())
print("收到html长度:",len(r['html']))
async def run(self):
await self.load_url() ##加载url
await self.crawl_main() ##启动爬虫程序
if __name__ == '__main__':
baidu = GetFast()
loop = asyncio.get_event_loop()
loop.run_until_complete(baidu.run())
```
نیازمندی
| مقدار | نام |
|---|---|
| ==1.3.1 | aioredis |
| ==3.8.1 | aiohttp |
| ==2.1.7 | cchardet |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.5.0 | Python |
نحوه نصب
نصب پکیج whl AioFastGet-0.0.7:
pip install AioFastGet-0.0.7.whl
نصب پکیج tar.gz AioFastGet-0.0.7:
pip install AioFastGet-0.0.7.tar.gz