Module: Cgh
- Defined in:
- lib/module/cgh.rb
Overview
國泰綜合醫院
Class Method Summary collapse
Class Method Details
.crawl ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# 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. return nil end return hash end |