开发者

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

开发者 https://www.devze.com 2023-01-03 00:28 出处:网络
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 \'op

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

精彩评论

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