module Shh

衛生福利部雙和醫院

Public Class Methods

crawl() click to toggle source
# File lib/module/shh.rb, line 3
def Shh.crawl
    hash = {}
    url = "http://eng.shh.org.tw/ER_WEB/ER_WEB/"
    begin
        html = open(url).read
        html.encode!("big5")
        page = Nokogiri::HTML.parse html
        hash[:hospital] = "shh"
        hash[:to_119]        = page.css("#off").text.strip
        hash[:wait_see]      = page.css("#Label1").text.strip
        hash[:wait_push_bed] = page.css("#Label2").text.strip
        hash[:wait_bed]      = page.css("#Label3").text.strip
        hash[:wait_cure_bed] = page.css("#Label4").text.strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end