基于py3异步的web抓取框架

crawler的Python项目详细描述


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

基于py3异步aiohttp库的web抓取框架。

用法示例

importrefromitertoolsimportislicefromcrawlerimportCrawler,RequestRE_TITLE=re.compile(r'<title>([^<]+)</title>',re.S|re.I)classTestCrawler(Crawler):deftask_generator(self):forhostinislice(open('var/domains.txt'),100):host=host.strip()ifhost:yieldRequest('http://%s/'%host,tag='page')defhandler_page(self,req,res):print('Result of request to {}'.format(req.url))try:title=RE_TITLE.search(res.body).group(1)exceptAttributeError:title='N/A'print('Title: {}'.format(title))bot=TestCrawler(concurrency=10)bot.run()

安装

pip install crawler

依赖关系

  • python=3.4
  • aiohttp

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Ejb@Schedule在elasticbeanstalk上运行的swarm应用程序中不起作用   oop在java中,接口是否可以从超级接口继承常量和方法?   来自JDBC的java PL/SQL调用导致“SQLSyntaxErrorException:ORA00900”   java在安卓中共享到应用程序时如何制作覆盖?   java Cardview是一张一卡通   从java中的类名实例化类   java无法获取HashMap中新Putte的元素?   使用iText库在PDF中生成java分层书签   java@Target属性值必须是类文本   java Spring绑定抽象对象   Java中类间的c JNI作用域   spring如何从java运行curl命令?   java如何计算死亡年龄?   swing动态JPanel加法   java生成计算机移动   java是多维数组的新成员   SpringMVCJava。lang.ClassNotFoundException:org。springframework。表示表达式分析器   java在运行时创建NinePatch