質問

So I am using this:

Net::HTTP.get(URI.parse(url))

Works perfect.

Issue I am having is that the page it gets is formatted with head, html, body, etc tags. There is a label element in the body with an id of "Result" I only want to get me back the text of "Result". Not all the html formatting.

Can this be done?

役に立ちましたか?

解決

Well, to get only a part of a content in HTML you have to use a HTML parser, which will be Nokogiri in this case .

doc = Nokogiri::HTML(open(url))
doc.css('#Result').each do |re|
  puts re.to_s
  #puts re.content
end
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top