Module: Cgmh_chayi

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

def Cgmh_chayi.crawl
    hash = {}
    url = "https://www.cgmh.org.tw/bed/erd/index.asp?loc=6"
    begin
        page = Nokogiri::HTML(open(url))
        hash[:hospital] = "cgmh_chayi"
        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
        hash
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end