module Cgmh_kl

長庚醫療財團法人基隆長庚紀念醫院

Public Class Methods

crawl() click to toggle source
# File lib/module/cgmh_kl.rb, line 3
def Cgmh_kl.crawl
    hash = {}
    url = "https://www.cgmh.org.tw/bed/erd/index.asp?loc=2"
    begin
        page = Nokogiri::HTML(open(url))

        hash[:hospital] = "cgmh_kl"
        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