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
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?
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