module Edah

義大醫療財團法人義大醫院

Public Class Methods

crawl() click to toggle source
# File lib/module/edah.rb, line 3
def Edah.crawl
    hash = {}
    url = "http://www3.edah.org.tw/E-DA/WebRegister/ProcessEmeInf.jsp"
    begin
        html = open(url).read
        html.encode!("big5")
        page = Nokogiri::HTML.parse html
        hash[:hospital] = "edah"
        hash[:to_119]        = self.split(page.css("body table tr:nth-child(1) td font").text.strip)
        hash[:wait_see]      = self.split(page.css("body table tr:nth-child(2) td font").text.strip)
        hash[:wait_push_bed] = self.split(page.css("body table tr:nth-child(3) td font").text.strip)
        hash[:wait_bed]      = self.split(page.css("body table tr:nth-child(4) td font").text.strip)
        hash[:wait_cure_bed] = self.split(page.css("body table tr:nth-child(5) td font").text.strip)
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end
split(text) click to toggle source
# File lib/module/edah.rb, line 23
def self.split(text)
    return text.split(":")[1]
end