跳转到主要内容

基于 py3 asyncio 的网站抓取框架

项目描述

https://travis-ci.org/lorien/iob.png?branch=master https://coveralls.io/repos/lorien/iob/badge.svg?branch=master https://pypip.in/download/iob/badge.svg?period=month https://pypip.in/version/iob/badge.svg https://landscape.io/github/lorien/iob/master/landscape.png

基于 py3 asyncio & aiohttp 库的 Web 抓取框架。

使用示例

import re
from itertools import islice

from iob import Crawler, Request

RE_TITLE = re.compile(r'<title>([^<]+)</title>', re.S | re.I)

class TestCrawler(Crawler):
    def task_generator(self):
        for host in islice(open('var/domains.txt'), 100):
            host = host.strip()
            if host:
                yield Request('http://%s/' % host, tag='page')

    def handler_page(self, req, res):
        print('Result of request to {}'.format(req.url))
        try:
            title = RE_TITLE.search(res.body).group(1)
        except AttributeError:
            title = 'N/A'
        print('Title: {}'.format(title))

bot = TestCrawler(concurrency=10)
bot.run()

安装

pip install iob

依赖关系

  • Python >= 3.4

  • aiohttp

项目详细信息


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

iob-0.0.2.tar.gz (6.7 kB 查看哈希值)

上传时间: 源代码

支持者:

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面