Module: Ntuh_yunlin

Defined in:
lib/module/ntuh_yunlin.rb

Class Method Summary collapse

Class Method Details

.crawlObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/module/ntuh_yunlin.rb', line 2

def Ntuh_yunlin.crawl
    hash = {}
    url = "http://reg.ntuh.gov.tw/EmgInfoBoard/Y0NTUHEmgInfo.aspx"
    begin
        html = open(url).read
        html.encode!("big5")
        page = Nokogiri::HTML.parse html
        hash[:hospital] = "ntuh_yunlin"
        hash[:wait_register] = page.css("#form1 table tr:nth-child(1) td:nth-child(2)").text.gsub("", "").strip
        hash[:wait_see]      = page.css("#form1 table tr:nth-child(2) td:nth-child(2)").text.gsub("", "").strip
        hash[:wait_bed]      = page.css("#form1 table tr:nth-child(3) td:nth-child(2)").text.gsub("", "").strip
        hash[:wait_icu     ] = page.css("#form1 table tr:nth-child(4) td:nth-child(2)").text.gsub("", "").strip
        hash[:wait_push_bed] = page.css("#form1 table tr:nth-child(5) td:nth-child(2)").text.gsub("", "").strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end