Created
March 30, 2009 04:06
-
-
Save no6v/87620 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'nokogiri' | |
module Jleague | |
module_function | |
def miniscore2mobile | |
uri = "http://www.tbs.co.jp/supers/miniscore#{rand( 3 ) + 1}.htm" | |
html = Nokogiri( open( $DEBUG ? 'test.html' : uri, &:read ) ) | |
tables = html / 'table' | |
[].tap {|text| | |
tables.each do |table| | |
(table / 'tr').each_slice(2) do |section, body| | |
text << (section / 'th').inner_text | |
date, games = body / 'td' | |
text << date.inner_text.chomp | |
(games / 'strong').each do |game| | |
text << game.inner_text | |
end | |
end | |
end | |
} * "\n" | |
end | |
end | |
if $0 == __FILE__ then | |
require 'nkf' | |
puts NKF::nkf( '-e -Z1', Jleague.miniscore2mobile ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment