Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top