Created
March 22, 2010 11:24
-
-
Save tatsuro-ueda/339984 to your computer and use it in GitHub Desktop.
天気予報(降水確率付き)を取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command tenki :!D:\mydoc\lookup-weather-forecast.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
uri = URI.parse('http://weather.jp.msn.com/RSS.aspx?wealocations=wc:JAXX0085&weadegreetype=C&culture=ja-JP') | |
require 'rss' | |
rss = RSS::Parser.parse(uri, false) | |
str = rss.channel.item(0).description | |
def ignore_html_tag(string) | |
string.gsub!(/<("[^"]*"|'[^']*'|[^'">])*>/, "")# 引用元:http://hodade.adam.ne.jp/seiki/page.php?r_tag_sakujo | |
end | |
ary = (ignore_html_tag str).split(/%/) | |
puts "#{ary[0]}% #{ary[1].gsub!(/°/, "")}%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment