module Mmh

財團法人臺灣基督長老教會馬偕紀念社會事業基金會馬偕紀念醫院

Public Class Methods

crawl() click to toggle source
# File lib/module/mmh.rb, line 3
def Mmh.crawl
    hash = {}
    url = "http://www.pohai.org.tw/pohai/bedqty_er/bedqty_er.php"
    begin
        page = Nokogiri::HTML(open(url))
        hash[:hospital] = "mmh"
        hash[:to_119]        = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(1)").text.strip
        hash[:wait_see]      = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(2)").text.gsub("人", "").strip
        hash[:wait_push_bed] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(3)").text.gsub("人", "").strip
        hash[:wait_bed]      = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(4)").text.gsub("人", "").strip
        hash[:wait_cure_bed] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(5)").text.gsub("人", "").strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end