module Sltung
Public Class Methods
crawl()
click to toggle source
# File lib/module/sltung.rb, line 9 def Sltung.crawl url = "http://www.sltung.com.tw/tw/BED/bed.html" begin page = Nokogiri::HTML(open(url)) text = page.css("body div.wrapper div span").text hash = self.get_situation(text) rescue Exception => e p e.message return nil end return hash end
get_situation(text)
click to toggle source
# File lib/module/sltung.rb, line 22 def self.get_situation(text) hash = {} hash[:hospital] = "sltung" text.split(":").each_with_index do |each_text, index| next if index == 0 if index == 1 hash[:to_119] = each_text.initial elsif index == 2 hash[:wait_see] = each_text.initial elsif index == 3 hash[:wait_push_bed] = each_text.initial elsif index == 4 hash[:wait_bed] = each_text.initial elsif index == 5 hash[:wait_cure_bed] = each_text.initial end end return hash end