Sha256: 9b9d1054af2f75669f777059169f309a8015c8658f976334b1846f5eb7214b5c

Contents?: true

Size: 610 Bytes

Versions: 52

Compression:

Stored size: 610 Bytes

Contents

require 'net/http'
require 'rexml/document'

# Web search for "madonna"
url = 'http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=2'

# get the XML data as a string
xml_data = Net::HTTP.get_response(URI.parse(url)).body

# extract event information
doc = REXML::Document.new(xml_data)
titles = []
links = []
doc.elements.each('ResultSet/Result/Title') do |ele|
   titles << ele.text
end
doc.elements.each('ResultSet/Result/Url') do |ele|
   links << ele.text
end

# print all events
titles.each_with_index do |title, idx|
   print "#{title} => #{links[idx]}\n"
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rack-app-11.0.2 spike/xml.rb
rack-app-11.0.1 spike/xml.rb
rack-app-11.0.0 spike/xml.rb
rack-app-10.0.0 spike/xml.rb
rack-app-9.0.0 spike/xml.rb
rack-app-8.1.0 spike/xml.rb
rack-app-8.0.1 spike/xml.rb
rack-app-8.0.0 spike/xml.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/spike/xml.rb
rack-app-7.7.0 spike/xml.rb
rack-app-7.6.5 spike/xml.rb
rack-app-7.6.4 spike/xml.rb
rack-app-7.6.3 spike/xml.rb
rack-app-7.6.2 spike/xml.rb
rack-app-7.6.1 spike/xml.rb
rack-app-7.6.0 spike/xml.rb
rack-app-7.5.2 spike/xml.rb
rack-app-7.5.1 spike/xml.rb
rack-app-7.5.0 spike/xml.rb
rack-app-7.4.0 spike/xml.rb