Module: Vghtc

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

def Vghtc.crawl
    hash = {}
    url = "http://www.vghtc.gov.tw/GipOpenWeb/wSite/sp?xdUrl=/wSite/query/Doctor/GetEmgBedInform.jsp&ctNode=55658&mp=1&idPath=213_55658"
    begin
        page = Nokogiri::HTML(open(url))
        hash[:hospital] = "vghtc"
        hash[:to_119]        = page.css("div.cp table tr:nth-child(2) td:nth-child(2) font b").text.strip
        hash[:wait_internal_medicine]      = page.css("div.cp table tr:nth-child(4) td:nth-child(2) font b").text.gsub("", "").strip
        hash[:wait_surgery] = page.css("div.cp table tr:nth-child(5) td:nth-child(2) font b").text.gsub("", "").strip
        hash[:wait_paediatrics]      = page.css("div.cp table tr:nth-child(6) td:nth-child(2) font b").text.gsub("", "").strip
        hash[:wait_push_bed] = page.css("div.cp table tr:nth-child(8) td:nth-child(2) font b").text.gsub("", "").strip
        hash[:wait_bed] = page.css("div.cp table tr:nth-child(10) td:nth-child(2) font b").text.gsub("", "").strip
        hash[:wait_cure_bed] = page.css("div.cp table tr:nth-child(12) td:nth-child(2) font b").text.gsub("", "").strip
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end