2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/module/wanfang.rb', line 2
def Wanfang.crawl
hash = {}
url = "http://www.wanfang.gov.tw/W402008web_new/epd_query.asp"
begin
page = Nokogiri::HTML(open(url))
hash[:hospital] = "wanfang"
hash[:to_119] = page.css("body table:nth-child(1) tr:nth-child(9) td:nth-child(1) table tr td ul:nth-child(3) li:nth-child(1)").text.strip
hash[:wait_see] = page.css("body table:nth-child(1) tr:nth-child(9) td:nth-child(1) table tr td ul:nth-child(3) li:nth-child(2)").text.gsub("人", "").strip
hash[:wait_push_bed] = page.css("body table:nth-child(1) tr:nth-child(9) td:nth-child(1) table tr td ul:nth-child(3) li:nth-child(3)").text.gsub("人", "").strip
hash[:wait_bed] = page.css("body table:nth-child(1) tr:nth-child(9) td:nth-child(1) table tr td ul:nth-child(3) li:nth-child(4)").text.gsub("人", "").strip
hash[:wait_cure_bed] = page.css("body table:nth-child(1) tr:nth-child(9) td:nth-child(1) table tr td ul:nth-child(3) li:nth-child(5)").text.gsub("人", "").strip
hash = self.split(hash)
rescue Exception => e
p e.message
return nil
end
return hash
end
|