動機
最近イントラでPlaggerを動かそうと思ったんですが、どうせならせっかくPythonやってるんでPython版Plaggerのhabuを動かしてみようかと思います。その練習としてMacで動かしてみます。
準備
自分のPythonのバージョンは2.5.2なのでhabuを動かすには問題ありません。(>= 2.4ならOKらしい)habuを動かすには下記の3つのモジュールをインストールしておく必要があるみたいです。
Universal Feed Parser
unzipしてinstallするだけという簡単な感じ。
$ unzip feedparser-4.1.zip $ python setup.py install (略)
PyYAML
PyYAMLはLibYAMLも入れておこうと思います。
$ tar xzf PyYAML-3.05.tar.gz $ cd PyYAML-3.05 $ python setup.py install $ python setup_with_libyaml.py install Traceback (most recent call last): File "setup_with_libyaml.py", line 6, in <module> from Pyrex.Distutils import build_ext ImportError: No module named Pyrex.Distutils
あ、Pyrex入れてない。というわけでインストール。
$ cd .. $ tar xzf Pyrex-0.9.8.4.tar.gz $ cd Pyrex-0.9.8.4 $ python setup.py install $ cd ../PyYAML-3.05 $ python setup_with_libyaml.py install (略) errorたくさん
だめだ。とりあえず後回し。
Twisted
$ bzip2 -dc Twisted-8.1.0.tar.bz2 | tar x $ cd Twisted-8.1.0 $ python setup.py install
これで下準備はおしまい。
habuの設定
- 【ハウツー】「habu」 - Python版PlaggerでRSSを加工する (2) habuの基本的な使い方 | エンタープライズ | マイナビニュース
- habu Wiki - SourceForge.JP
ここにあるようにhabu.cfgを若干変更してpython.cfgを書いてみた。変更に関してはプロジェクトのWiki参照。
global: timezone: Asia/Tokyo log: stdout pipeline: rss_fetcher: - module: subscription.config config: feed: - http://d.hatena.ne.jp/ymotongpoo/rss2 - http://b.hatena.ne.jp/hotentry?mode=rss&cname=elec - module: filter.join - module: filter.grep config: str: summary: python - module: filter.sort config: reverse: True - module: publisher.rssfeeder config: file: "out.rss"
これを使ってhabuを走らせてみます。
$ python runhabu.py python.cfg
で、out.rssを見てみるとちゃんとPythonに関係ある記事だけを吸い出してました。すばらしい。