module Vghtpe

台北榮民總醫院

Public Class Methods

crawl() click to toggle source
# File lib/module/vghtpe.rb, line 3
def Vghtpe.crawl
    hash = {}
    url = "https://www6.vghtpe.gov.tw/ERREALIFO/ERREALIFO.jsp"
    begin
        page = Nokogiri::HTML(open(url))
        hash[:hospital] = "vghtpe"
        hash[:to_119]        = page.css("body table:nth-child(3) tr:nth-child(1) td:nth-child(2) font").text.strip
        hash[:wait_see]      = page.css("body table:nth-child(3) tr:nth-child(2) td:nth-child(2) font").text.strip
        hash[:wait_push_bed] = page.css("body table:nth-child(3) tr:nth-child(3) td:nth-child(2) font").text.strip
        hash[:wait_bed]      = page.css("body table:nth-child(3) tr:nth-child(4) td:nth-child(2) font").text.strip
        hash[:wait_cure_bed] = page.css("body table:nth-child(3) tr:nth-child(5) td:nth-child(2) font").text.strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end