Fess で Twilog を検索する

全文検索システムの Fess で note や WordPress を検索できるようにしたと書いた。

Fess で note を検索にする – with a Christian Wife
https://wacw.cf/2020/07/03/indexing-note-with-fess/

Fess で WordPress を検索する – with a Christian Wife
https://wacw.cf/2020/07/04/indexing-wordpress-with-fess/

次は Twilog を検索したい。対象とするのは以下のページだ。

Christian Wife(@wachristianwife) – Twilog
https://twilog.org/wachristianwife

Twilog は日付別、月別、ハッシュタグ別等で Twitter の投稿を見ることができるようになっている。やりたいことは、検索結果として Twilog の日付別ページが表示されるようにすることだ。

なお、Twitter のページを Fess でクローリングしようとしたが、これはうまくいかなかった。

note や WordPress で Fess の設定をしてきて、だんだん慣れてきたとおもったら、Twilog は note や WordPress とは違うトラップがあった。Twilog には robots.txt の設定がしてあるようで、クローリングができないようになっている。

これを回避するには、/app/WEB-INF/classes/fess_config.properties の 204、205 行目あたりを以下のように変更する。

変更前:

crawler.ignore.robots.txt=false
crawler.ignore.robots.tags=false

変更後:

crawler.ignore.robots.txt=true
crawler.ignore.robots.tags=true

これで robots.txt によるクローリング禁止を回避できる。

参考:
FESS 13.2.0 ウェブクロールの設定ができた : Linux備忘録&ちょっと休憩しましょ
http://blog.livedoor.jp/linuxer2006/archives/65949570.html

では、Fess の設定をしていこう。

「Admin ページ>MENU>Crawler>Web」で新規に Web Crawling を作成し、以下のように設定する。

・Name
Twilog(適当に設定)

・URLs
https://twilog.org/withachristianwife

・Included URLs For Crawling
https://twilog.org/withachristianwife.*

・Excluded URLs For Crawling

https://twilog.org/withachristianwife/stats
https://twilog.org/withachristianwife/friends.*
https://twilog.org/withachristianwife/hashtags.*
https://twilog.org/withachristianwife/monthlist.*

・Included URLs For Indexing
https://twilog.org/withachristianwife/date-.*

・Excluded URLs For Indexing
(空白;デフォルト値)

・Config Parameters
(空白;デフォルト値)

・Depth
5(とりあえず 5 とした)

・Max Access Count
2000(投稿日数より大きめの値にする。投稿日数は Twilog の統計ページで確認できる。)

・User Agent
Mozilla/5.0 (compatible; Fess/13.7; +http://fess.codelibs.org/bot.html)(デフォルト値)

・The number of Thread
1

・Interval time
10000ms (デフォルト値)

・Boost
1.0 (デフォルト値)

・Permissions
(デフォルト値)

・Virtual Hosts
(空白;デフォルト値)

・Status
Enabled

・Description
(空白;デフォルト値)

* * *

一応検索できる状態にはなったが、対象から漏れているページがあるような気がする。。

Twilog のページをよく観察すると、日付別ページ内には「すべての年の同日ツイート」というボタンがある。このリンクをクリックすると、年をまたいで例えば5月 13 日のツイートを見ることができるが、こういうページは検索しなくていい。しかし検索対象外にしようとしても、うまくいかなかった(正規表現がうまく働かなかった)。

Twilog のクローリングにはやたら時間が掛かる。投稿数が多い Twitter だと大変だ。Raspberry Pi で、Twilog 専用の Fess を立てようかな。

Twilog の設定は結構苦労した。その過程で学んだことは、「効率よく巡回するにはどうすればいいか」を意識することだ。できるだけ関係ないページはクローリングの対象外にするようにしたりと、いろいろ考えた。