Module: Ntuh_taipei

Defined in:
lib/module/ntuh_taipei.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
20
21
# File 'lib/module/ntuh_taipei.rb', line 3

def Ntuh_taipei.crawl
    hash = {}
    url = "https://reg.ntuh.gov.tw/EmgInfoBoard/NTUHEmgInfo.aspx"
    begin
        html = open(url).read
        html.encode!("big5")
        page = Nokogiri::HTML.parse html
        hash[:hospital] = "ntuh_taipei"
        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