module Pohai
財團法人羅許基金會羅東博愛醫院
Public Class Methods
crawl()
click to toggle source
# File lib/module/pohai.rb, line 3 def Pohai.crawl hash = {} url = "http://www.pohai.org.tw/pohai/bedqty_er/bedqty_er.php" begin page = Nokogiri::HTML(open(url)) hash[:hospital] = "pohai" hash[:to_119] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(1)").text.strip hash[:wait_see] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(2)").text.gsub("人", "").strip hash[:wait_push_bed] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(3)").text.gsub("人", "").strip hash[:wait_bed] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(4)").text.gsub("人", "").strip hash[:wait_cure_bed] = page.css("table tr:nth-child(2) td table tr:nth-child(2) td:nth-child(5)").text.gsub("人", "").strip rescue Exception => e p e.message return nil end return hash end