Module: Mmh

Defined in:
lib/module/mmh.rb

Overview

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

Class Method Summary collapse

Class Method Details

.crawlObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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