Skip to content

Instantly share code, notes, and snippets.

@tatsuro-ueda
Created March 22, 2010 11:24
Show Gist options
  • Save tatsuro-ueda/339984 to your computer and use it in GitHub Desktop.
Save tatsuro-ueda/339984 to your computer and use it in GitHub Desktop.
天気予報(降水確率付き)を取得する
command tenki :!D:\mydoc\lookup-weather-forecast.rb
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!(/&#176;/, "")}%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment