开发者

Parse a certain value ie current temperature from a website using RUBY

I have to parse only the 'current temperature' value in a webpage and display it. Kindly help m开发者_如何学Ce out please.


I highly recommend you using Nokogiri. Here's a good overview.


require 'open-uri'

data =''
open("http://some.site/page/address") do |f| // adjust URI here
  data << f.read while !f.eof?
end
temp = data[/current temperature: [0-9]+/]   // and regex here
p temp
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜