module Ktgh_shalu
光田醫療社團法人光田綜合醫院(沙鹿總院)
Public Class Methods
crawl()
click to toggle source
# File lib/module/ktgh_shalu.rb, line 3 def Ktgh_shalu.crawl hash = {} url = "http://www.ktgh.com.tw/BednoInfo_Show.asp?CatID=80&ModuleType=Y" begin html = open(url).read html.encode!("big5") page = Nokogiri::HTML.parse html hash[:hospital] = "ktgh_shalu" # hash[:to_119] = page.css("#off").text.strip hash[:wait_see] = page.css("#Table3 > tr:nth-child(2) > td > table:nth-child(2) tr:nth-child(2) td:nth-child(2)").text.strip hash[:wait_push_bed] = page.css("#Table3 > tr:nth-child(2) > td > table:nth-child(2) tr:nth-child(2) td:nth-child(3)").text.strip hash[:wait_bed] = page.css("#Table3 > tr:nth-child(2) > td > table:nth-child(2) tr:nth-child(2) td:nth-child(4)").text.strip hash[:wait_cure_bed] = page.css("#Table3 > tr:nth-child(2) > td > table:nth-child(2) tr:nth-child(2) td:nth-child(5)").text.strip rescue Exception => e p e.message return nil end return hash end