Module: Vghtpe

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

def Vghtpe.crawl
    hash = {}
    url = "https://www6.vghtpe.gov.tw/ERREALIFO/ERREALIFO.jsp"
    begin
        page = Nokogiri::HTML(open(url))
        hash[:hospital] = "vghtpe"
        hash[:to_119]        = page.css("body table:nth-child(3) tr:nth-child(1) td:nth-child(2) font").text.strip
        hash[:wait_see]      = page.css("body table:nth-child(3) tr:nth-child(2) td:nth-child(2) font").text.strip
        hash[:wait_push_bed] = page.css("body table:nth-child(3) tr:nth-child(3) td:nth-child(2) font").text.strip
        hash[:wait_bed]      = page.css("body table:nth-child(3) tr:nth-child(4) td:nth-child(2) font").text.strip
        hash[:wait_cure_bed] = page.css("body table:nth-child(3) tr:nth-child(5) td:nth-child(2) font").text.strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end