Skip to content

Instantly share code, notes, and snippets.

@no6v
Created March 30, 2009 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save no6v/87620 to your computer and use it in GitHub Desktop.
Save no6v/87620 to your computer and use it in GitHub Desktop.
#!/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