# -*- coding: utf-8 -*- require 'net/http' require 'kconv' module ConsadoleAggregator module Live module Parser BASE_URI = URI.parse('http://www.consadole-sapporo.jp/view/s674.html') TimeLine = Struct.new :time, :post do def initialize line tmp = line.split self['time'] = tmp[0] self['post'] = tmp[1] end end def Parser.parse response = Net::HTTP.get(BASE_URI).force_encoding("Shift_JIS") doc = Nokogiri::HTML.parse(response.toutf8, nil, 'UTF-8') doc.search('hr + p').last.inner_html.gsub(/
/,'').split("\n").map{ |line| TimeLine.new line unless /<ε‰εŠ>|<後半>/ =~ line }.compact.reverse end end end end