最新消息:

几个Python下用于screen scraping的工具集

技术 2224浏览 0评论

几个在python下用于处理模板文件或解析html页面的工具集合,也即所谓的“Screen Scraping”。比用python 基础包的robotparser及htmlparser方便多了,也比直接用正则表达式效率高多了。一般而言,对于html页面的解析(搜索引擎的spider必须要做的事情)应该有如下几种方式处理:

1、正则表达式。

2、如果文件为xhtml的话(如果为普通html,可以借助诸如tidy转化为xhtml),对xhtml直接用xpath解析。

3、借助xml解析器对xhtml页面按照dom树或sax方式进行解析

  • BeautifulSoup

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

  • templatemaker

http://www.holovaty.com/blog/archive/2007/07/06/0128

  • webstemmer

http://www.unixuser.org/~euske/python/webstemmer/

  • twill(基于BeautifulSoup)

http://twill.idyll.org/

  • Perl版本的工具

http://www.perl.com/lpt/a/980

http://search.cpan.org/dist/Template-Extract/

http://search.cpan.org/~petdance/WWW-Mechanize/

http://search.cpan.org/dist/FEAR-API/

  • Ruby版本的工具

http://code.whytheluckystiff.net/hpricot/  基于HTreeJQuery

http://scrubyt.org/

http://ariel.rubyforge.org/

  • Java版本的工具

HTML Screen Scraping Tools Written in Java

好像没有提到http://htmlparser.sourceforge.net/,挺方便的。

 

PS .发现两个不错的服务,有空研究一下:

  • 自定义API的工具dapper:

 http://www.dapper.net/,有空研究一下怎样利用以上工具实现

  • MIT的个人信息门户piggy-bank及Solvent

以前看过,基于firefox插件的,piggy-bank的思路很值得借鉴,尤其是做个人门户。

http://simile.mit.edu/wiki/Solvent

http://simile.mit.edu/piggy-bank/

 

转载请注明:出家如初,成佛有余 » 几个Python下用于screen scraping的工具集

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址