基于 py3 asyncio 的网站抓取框架
项目描述
基于 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 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a86440277b1d91996c1f6c1c33a1219790962a504350adfc1f14771936bc3a77 |
|
MD5 | 42887a143f13d1c59f09ad8786084036 |
|
BLAKE2b-256 | d69b4d2dadb823bdd27fe2ca45f19e33dce4d3aac3d02efa3a6087bd561bc145 |