module Cgmh_ks

長庚醫療財團法人高雄長庚紀念醫院

Public Class Methods

crawl() click to toggle source
# File lib/module/cgmh_ks.rb, line 3
def Cgmh_ks.crawl
    hash = {}
    url = "https://www.cgmh.org.tw/bed/erd/index.asp?loc=8"
    begin
        page = Nokogiri::HTML(open(url))
        hash[:hospital] = "cgmh_ks"
        hash[:to_119]        = page.css("table:nth-child(1) tr:nth-child(5) td table  tr:nth-child(3) td:nth-child(2) font").text.strip
        hash[:wait_see]      = page.css("table:nth-child(1) tr:nth-child(5) td table  tr:nth-child(4) td:nth-child(2) font").text.strip
        hash[:wait_push_bed] = page.css("table:nth-child(1) tr:nth-child(5) td table  tr:nth-child(5) td:nth-child(2) font").text.strip
        hash[:wait_bed]      = page.css("table:nth-child(1) tr:nth-child(5) td table  tr:nth-child(6) td:nth-child(2) font").text.strip
        hash[:wait_cure_bed] = page.css("table:nth-child(1) tr:nth-child(5) td table  tr:nth-child(7) td:nth-child(2) font").text.strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end