基于python的crawler | 出家如初,成佛有余
基于python的crawler | 出家如初,成佛有余

基于python的crawler
Posted 五月 16, 2009 * Comments(3)

考虑到垂直爬虫及站内搜索的重要性,重新思考一下项目爬虫的技术架构及实现方案。以前的垂直爬虫曾经使用过heritrix、htmlparser、nutch等,各有优缺点。尤其是要做垂直网站的定向爬取时候,并没有太好的方案,只能够做指定页面的定向解析,因此以前主要还是使用htmlparser的方案。

考察垂直爬虫的几个原则:

性能较高:较好支持多线程并发处理;支持异步、非阻塞socket;支持分布式爬取;爬取调度算法性能较高;内存使用效率较高,不要老是出现out of memory问题;
架构优美:组件式设计式架构,扩展方便;架构设计精巧。至少值得花时间去学习架构设计思想。
扩展方便:能够与现有框架较好集成;由于是垂直爬虫,需要针对不同的网页定制爬取规则集逻辑,需要能够方便测试,不要老是重新编译,因此最好支持python等脚本语言
功能全面:内置支持ajax/javascript爬取、登录认证、深度爬取设置、类似heritrix的爬取过滤器(filter)、页面压缩处理等
管理功能:提供爬虫管理接口,能够实时监控和管理爬取

厌烦了基于java的爬虫方案,尤其是考虑到python在网络编程上的易用性,因此打算考察基于python做新版本爬虫的可行性,刚好把久不使用的python捡起来。

整理了一下目前基于python的crawler,大致有如下一些现成的项目方案可供参考:

Mechanize:http://wwwsearch.sourceforge.net/mechanize/

Twill:http://twill.idyll.org/

Scrapy:http://scrapy.org

HarvestMan:http://www.harvestmanontheweb.com/

Ruya:http://ruya.sourceforge.net/

psilib:http://pypi.python.org/pypi/spider.py/0.5

BeautifulSoup + urllib2:http://www.crummy.com/software/BeautifulSoup/

比较之后,选择Scrapy作为重点考察学习对象,尽管没有Mechanize及Harvestman成熟,但从其架构来看,还是很有前途的,尤其是基于twisted高性能框架的架构,很有吸引力。

看看Scrapy的架构:

scrapy_architecture1
Components

Scrapy Engine

The engine is responsible for controlling the data flow between all components of the system, and triggering events when certain actions occur. See the Data Flow section below for more details.

Scheduler

The Scheduler receives requests from the engine and enqueues them for feeding them later (also to the engine) when the engine requests them.

Downloader

The Downloader is responsible for fetching web pages and feeding them to the engine which, in turns, feeds them to the spiders.

Spiders

Spiders are custom classes written by Scrapy users to parse response and extract items (aka scraped items) from them or additional URLs (requests) to follow. Each spider is able to handle a specific domain (or group of domains). For more information see Spiders.

Item Pipeline

The Item Pipeline is responsible for processing the items once they have been extracted (or scraped) by the spiders. Typical tasks include cleansing, validation and persistence (like storing the item in a database). For more information see Item Pipeline.

Downloader middlewares

Downloader middlewares are specific hooks that sit between the Engine and the Downloader and process requests when they pass from the Engine to the downloader, and responses that pass from Downloader to the Engine. They provide a convenient mechanism for extending Scrapy functionality by plugging custom code. For more information see Downloader Middleware.

Spider middlewares

Spider middlewares are specific hooks that sit between the Engine and the Spiders and are able to process spider input (responses) and output (items and requests). They provide a convenient mechanism for extending Scrapy functionality by plugging custom code. For more information see Spider Middleware.

Scheduler middlewares

Spider middlewares are specific hooks that sit between the Engine and the Scheduler and process requests when they pass from the Engine to the Scheduler and vice-versa. They provide a convenient mechanism for extending Scrapy functionality by plugging custom code.

参考资料:

http://doc.scrapy.org

http://stackoverflow.com/questions/419235/anyone-know-of-a-good-python-based-web-crawler-that-i-could-use

http://en.wikipedia.org/wiki/Web_crawler#Open-source_crawlers

http://java-source.net/open-source/crawlers
Technorati 标签: crawler,spider,python,scrapy,mechanize,beautifulsoup,twisted,framework

站内标签:crawler,spider,python,scrapy,mechanize,beautifulsoup,twisted,framework

posted on 2011-10-26 13:43  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2011/10/26/2225135.html

基于python的crawler | 出家如初,成佛有余相关推荐

  1. 基于python爬虫数据处理_基于Python爬虫的校园数据获取

    苏艺航 徐海蛟 何佳蕾 杨振宇 王佳鹏 摘要:随着移动时代的到来,只适配了电脑网页.性能羸弱的校园教务系统,已经不能满足学生们的移动查询需求.为此,设计了一种基于网络爬虫的高实用性查询系統.它首先通过 ...

  2. 基于python爬虫技术的应用_基于Python爬虫技术的应用

    办公自动化杂志 一.引言 本文主要是对 Python 爬虫技术进行阐述,基于 python 的爬虫与其他语言相比的有很多优势.通过爬去某个网站的所有新闻这个案例,来进一步阐释 Python 爬虫技术的 ...

  3. 基于Python(Django)+MongoDB实现的(Web)新闻采集和订阅系统【100010319】

    本科生毕业论文(设计) 基于网络爬虫的新闻采集和订阅系统的设计与实现 [摘 要] 随着互联网的迅速发展,互联网大大提升了信息的产生和传播速度,网络上每天都会产生大量的内容,如何高效地从这些杂乱无章的内 ...

  4. 基于python的学生成绩管理系统毕业设计源码071143

    Django学生成绩管理 摘   要 在国家重视教育影响下,教育部门的密确配合下,对教育进行改革.多样性.质量等等的要求,使教育系统的管理和运营比过去十年前更加理性化.依照这一现实为基础,设计一个快捷 ...

  5. 基于Python的招聘网站爬虫及可视化的设计与实现

    摘 要 I Abstract II 引 言 1 第1章 课题概述 2 1.1 课题内容 2 1.2 课题背景 2 1.3 课题意义 3 1.4 运行环境 3 1.5 相关技术 3 1.5.1 Pyth ...

  6. 基于Python的新闻聚合网站设计与实现

    摘 要:本论文研究内容是基于Python的爬虫网络设计,利用Python的Scrapy的框架搭建爬虫网络,并设计一个全新的新闻网站,网站实现对新闻数据的分类,以及用户对新闻的分享.评论等,且本论题设计 ...

  7. (附源码)基于Python的“书怡”在线书店系统的设计与实现 毕业设计082332

    Django书怡在线书店系统 摘 要 随着科学技术的飞速发展,社会的方方面面.各行各业都在努力与现代的先进技术接轨,通过科技手段来提高自身的优势,在线书店系统当然也不能排除在外.书怡在线书店系统是以实 ...

  8. (附源码)python+mysql+基于python的学生成绩管理系统 毕业设计071143

    Django学生成绩管理 摘 要 在国家重视教育影响下,教育部门的密确配合下,对教育进行改革.多样性.质量等等的要求,使教育系统的管理和运营比过去十年前更加理性化.依照这一现实为基础,设计一个快捷而又 ...

  9. python+mysql+基于python的学生成绩管理系统 毕业设计-附源码071143

    Django学生成绩管理 摘   要 在国家重视教育影响下,教育部门的密确配合下,对教育进行改革.多样性.质量等等的要求,使教育系统的管理和运营比过去十年前更加理性化.依照这一现实为基础,设计一个快捷 ...

最新文章

  1. 精选26个Python实用技巧,想秀技能先Get这份技术列表!
  2. Faster-RCNN
  3. Python安装selenium启动浏览器
  4. Android 入职感想
  5. 如何打开笔记本电脑的摄像头_Win8系统笔记本电脑摄像头无法使用的解决办法...
  6. Python中的getpass模块
  7. 牛顿法python实现_牛顿法求极值及其Python实现
  8. HDU2548 两军交锋【数学计算+水题】
  9. 搭建Sublime Text3 Java编译运行环境
  10. java day18【线程池、Lambda表达式】
  11. Windows 8家长控制
  12. mac推箱子c语言,c语言写的推箱子源码,非常适合新手学习
  13. html 强制占据一行,html – 如何强制内联div保持在同一行?
  14. win8 不显示计算机,Win8电脑插上U盘不显示盘符怎么办?
  15. 【IoT】产品设计:拼多多商业模式分析:互联网是商业模式的竞技场
  16. Activiti 从入门到精通
  17. 数据中心交换机基础自学系列 | 汇总
  18. 【SRE笔记 2022.8.25 linux用户组及用户命令】
  19. Ubuntu18.04+ROS melodic 安装调用 RealSense L515
  20. 单调递增最长子序列 拦截导弹(nyoj 17 nyoj 79)

热门文章

  1. 使用node搭建服务器(wifi连接查看vue项目)
  2. pc伪装手机浏览器/平台
  3. 不用找,你想要的印章/雕刻装饰模板素材都在这里
  4. NFS服务器的介绍与配置,史上大总结,含泪肝数夜
  5. win11任务栏时间显示到秒的操作方法
  6. 前端学习之表格、列表相关属性
  7. Java中String类型与Map类型互转
  8. SiteSucker Pro Mac(Mac网站数据下载神器)
  9. 解压命令linux tgz,linux tgz命令详解
  10. 【UE4】界面打开关闭异常闪退