miki eto's memo

January 23, 2009

鎌団子にPerlを教える「スクレイピング編その1」をRubyで書いてみた

Filed under: Web/Tech — mikieto @ 3:48 am

Perlより、シンプルに書けるみたいだ。

require 'open-uri'
require 'nkf'

url	= "http://bokete.jp/user/kamadango/boke";
content = open(url).read

content = NKF.nkf("-w", content)
counts	= content.scan(/★の合計.*?(\d+)/).map { |x| x[0] }

total	= 0
counts.each { |count|
	total += count.to_i
}

print "total: " + total.to_s + "\n";

ゆーすけべー日記: 鎌団子にPerlを教える「スクレイピング編その1」
http://yusukebe.com/archives/09/01/20/143705.html

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.