Skip to main content

AsyncioFastGetFrame

Project description

01、Installation

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

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())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AioFastGet-0.0.7-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file AioFastGet-0.0.7-py2.py3-none-any.whl.

File metadata

  • Download URL: AioFastGet-0.0.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.3

File hashes

Hashes for AioFastGet-0.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c1c85115ad7f7da35d7573bb5b8730fd7fe40695a76386ba071dfb67b6dfdcbc
MD5 1458756518d4e770077f08ee88123d69
BLAKE2b-256 456bae8365dfcf2939f92ca7432bd23e1dd0788cdf79a7bdd63a52e98b180491

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page