コトノハde chat

コトノハから質問文を引っ張ってきて、
チャットで話のねたにするためのスクリプトを作成中。

とりあえず今日はコトノハのページをとってくるまで。

require 'mechanize'
require 'rubygems'
#I don't know why for what rubygems needed, but it is written in "GUIDE" of mechanize to reqire ruby gems.
require 'nkf'
#just memo for me. how to use nkf.
#NKF.nkf("-W-s", str) unicode -> SJIS
#NKF.nkf("-S-w", str) SJIS -> unicode

file = open("output.txt", "w")

agent = WWW::Mechanize.new
page = agent.get_file("http://kotonoha.cc/index.php")

file.print page

#wanna get all texts between <a href="/no/[0-9]*"> and </a> in page