3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/module/mmh.rb', line 3
def Mmh.crawl
hash = {}
url = "http://www.pohai.org.tw/pohai/bedqty_er/bedqty_er.php"
begin
page = Nokogiri::HTML(open(url))
hash[:hospital] = "mmh"
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
|