python の crawler 調査
仕事でちょっと必要だったので、python で動く crawler(Web ページを集めまくるツール)を調べてみました。
まずは Python Cheese Shop で crawler をキーワードに検索。すると以下のものがヒットしました。
- HarvestMan 1.4.6 final Multithreaded Offline Browser/Web Crawler
- Orchid 1.0 Generic Multi Threaded Web Crawler
- spider.py 0.5 Multithreaded crawling, reporting, and mirroring for Web and FTP
- webstemmer 0.6.0 A web crawler and HTML layout analyzer
- SpideyAgent 0.75 Each user can run their own threaded search engine and contribute to a global search database searching only the sites they want
それぞれの概要とパッと見の感想は以下のとおりです。
HarvestMan
- ホームページ: http://harvestman.freezope.org/
HarvestMan is a multithreaded off-line browser.It has many features for customizing offline browsing through URL filters, depth-fetching, fetch levels, domain filters, file limits, thread limits, download depth, directory checking, and robot exclusion protocol. It is useful to download an entire Web site or certain files from a Web site to the hard disk for offline browsing later.
- ライセンス: GPL
- ぱっと見: crawler というよりは off-line browser というのが中心っぽい。ちょっとやりたいことに対しては冗長すぎるかも。
Orchid
Orchid is a python crawler I developed for one of my graduate courses. It is a generic multi-threaded web crawler complete with documentation. We used this crawler to locate web pages which contained malicious code. However, the logic of what to do with the crawled pages is implemented in a separate class and therefore Orchid can easily be used for any application which requires crawling the web.
- ライセンス: 未定義
- ぱっと見: crawler に特化して作られたらしい。よさげ。でもドキュメントが...
spider.py
- ホームページ: http://psilib.sf.net/
This module provides multithreaded crawling, reporting, and mirroring for Web and FTP in one convenient library. Crawling depth, maximum number of URLs to crawl, and maximum number of threads are user-configurable. Reports can be generated on external URLS, internal redirects to outside URLs, unparsable HTML, non-HTTP/FTP URLs, and broken links.
- ライセンス: BSD
- ぱっと見: 一つのファイルで完結しているので、扱いやすそう。参考にもしやすそうで本命かも。
webstemmer
Webstemmer is a web crawler and HTML layout analyzer. It extracts articles from news sites as plain text and removes banners, ads and/or navigation links automatically. You only need to give a URL of the top page of a site and it works in an almost fully automatic way with little human intervention.
- ライセンス: MIT
- ぱっと見: 開発者が日本の方らしい。HTML レイアウトの解析はニュースサイトの同じ形をしたページを解析とかに使うらしい。そのあたりの機能を違う形にできたら面白いかも。
SpideyAgent
Each user can run their own threaded search engine and contribute to a global search database searching only the sites they want
- ライセンス: BSD, GPL
- 必須: MySQL, Turbogears
- まっと見: 上にある spider.py を使って crawl する制御を行う部分みたい。というわけで今後の参考にはなるかも知れないけど、とりあえずは置いておく。
調査開始
というわけでよさげかな?と思われる HarvestMan, Orchid, spider.py の3つを使ってみることにしました。
結論から言うと、とりあえず spider.py で行こうかなと思っています。
あ、やろうとしているのは「特定サイトのページからリンク先をクロール」→「抽出したページから特定のデータを抜き出す」→「それをデータベースとかに保存する」ってことです。
Orchid はよさげなんですけど、最初に書いたとおりドキュメントが API のドキュメントしかなくって。実際の使い方とかが??な感じです。調べてみてもいいんですが他の選択肢を試してみてからとおもいました。
HarvestMan は結構いい感じです。外部ファイルに設定項目を書いたりできるんですけど、あれこれ項目が多すぎてちょっと何がなにやらよくわからない感じでした。 あと、個人的に致命的だったのは「クリッカブルマップ」に対応していないということ。(今回は対応していないとマズいのです) ちょっとコードをいじったら対応してくれそうでしたが、それでうまく動作しているのかちょっとわからない漢字でした。
で、最後に spider.py これは単純にクロールして URL を取得してって感じでシンプルなので、自分の方でどうとでもなりそうかなと。 簡単な使い方は test_spider.py というコードを見れば一目瞭然。とりあえずこいつを使ってみようかなと思っています。 (というか先日のプロトタイプのプロトタイプみたいなものを見せるときに使いました。)
あとは深く調べていないんですが、websteemer のページを解析する部分はいろいろ参考になるかもと思っているので、今後調べてみるかもといった感じです。
とりあえずこの仕事がどうなるかは返答待ちだったりするので、とりあえずここまで。
- カテゴリ
-
plone
-
- ¦
- 固定リンク
- ¦
- コメント (3)
- ¦
- トラックバック (0)
- トラックバック用URL:
- http://takanory.net/takalog/540/tbping
鈴木たかのりです。とりあえず日記っぽく雑多なことを書き込んでいこうと思っています。
zope/plone関係の技術的な内容については
いつも楽しく拝見しています。
もしお気づきでなかったらと思いましてコメントしました。
後半、HTML タグ? が適用されていないようで少々読みづらいです...。
あーー、気づいてませんでした。
直しておきました。
ご指摘ありがとうございます。
後半 StructuredText で書いたのに、HTML だよって指定してました。すみませぬ。
Pythonで開発されたクローラーで、開発者向けのものです。
http://ruya.sourceforge.net/