module Cgh
國泰綜合醫院
Public Class Methods
crawl()
click to toggle source
# File lib/module/cgh.rb, line 3 def Cgh.crawl hash = {} url = "http://med.cgh.org.tw/unit/branch/Pharmacy/ebl/RealTimeInfoHQ.html" begin page = Nokogiri::HTML(open(url)) hash[:hospital] = "cgh" hash[:to_119] = page.css("center table tr:nth-child(1) td:nth-child(3)").text.strip hash[:wait_see] = page.css("center table tr:nth-child(2) td:nth-child(3)").text.strip hash[:wait_push_bed] = page.css("center table tr:nth-child(3) td:nth-child(3)").text.strip hash[:wait_bed] = page.css("center table tr:nth-child(4) td:nth-child(3)").text.strip hash[:wait_cure_bed] = page.css("center table tr:nth-child(5) td:nth-child(3)").text.strip rescue Exception => e p e.message return nil end return hash end