Sha256: 45106f6a661bec42d1443b631717a15c526d2db46842f37ac42e8692b2663721

Contents?: true

Size: 1.21 KB

Versions: 9

Compression:

Stored size: 1.21 KB

Contents

#coding: utf-8
require 'wombat'

class XmlCrawler
  include Wombat::Crawler

  base_url "http://ws.audioscrobbler.com"
  path "/2.0/?method=geo.getevents&location=#{URI.escape('San Francisco')}&api_key=ENV['API_KEY']"
  
  document_format :xml

  title "xpath=//event/title"

  locations 'xpath=//event', :iterator do
    latitude "xpath=./venue/location/geo:point/geo:lat", :text, { 'geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#' }
    longitude "xpath=./venue/location/geo:point/geo:long", :text, { 'geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#' }
  end
end

=begin
pp XmlCrawler.new.crawl

{
	"title"=>"Sinéad O'Connor",
 	"locations"=>[
 		{"latitude"=>"37.807717", "longitude"=>"-122.270059"},
   	{"latitude"=>"37.76213", "longitude"=>"-122.419032"},
   	{"latitude"=>"37.771491", "longitude"=>"-122.413241"},
   	{"latitude"=>"37.776227", "longitude"=>"-122.42044"},
   	{"latitude"=>"37.766588", "longitude"=>"-122.430391"},
   	{"latitude"=>"37.788978", "longitude"=>"-122.40664"},
   	{"latitude"=>"37.769715", "longitude"=>"-122.420427"},
   	{"latitude"=>"37.78832", "longitude"=>"-122.446692"},
   	{"latitude"=>"37.787583", "longitude"=>"-122.421665"},
   	{"latitude"=>"37.776227", "longitude"=>"-122.42044"}
	]
}
=end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
wombat-2.4.0 examples/xml.rb
wombat-2.3.0 examples/xml.rb
wombat-2.2.1 examples/xml.rb
wombat-2.2.0 examples/xml.rb
wombat-2.1.3 examples/xml.rb
wombat-2.1.2 examples/xml.rb
wombat-2.1.1 examples/xml.rb
wombat-2.1.0 examples/xml.rb
wombat-2.0.1 examples/xml.rb