module Csh
中山醫學大學附設醫院
Public Class Methods
crawl()
click to toggle source
# File lib/module/csh.rb, line 3 def Csh.crawl hash = {} url = "http://www.csh.org.tw/ER/index.aspx" begin html = open(url).read html.encode!("big5") page = Nokogiri::HTML.parse html hash[:hospital] = "csh" hash[:wait_see] = page.css("#WaitVisitCount").text.strip hash[:wait_push_bed] = page.css("#WaitErBedCount").text.strip hash[:wait_bed] = page.css("#WaitInpBedCount").text.strip hash[:wait_cure_bed] = page.css("#WaitInpBedCount").text.strip hash[:wait_internal_medicine] = page.css("#WaitBedInME").text.strip hash[:wait_surgery] = page.css("#WaitBedInSE").text.strip hash[:wait_paediatrics] = page.css("#WaitBedInPE").text.strip hash[:wait_gynaecology] = page.css("#WaitBedInGE").text.strip hash[:wait_other] = page.css("#WaitBedOthers").text.strip hash[:to_119] = page.css("#ReportStatus").text.strip rescue Exception => e p e.message return nil end return hash end