Skip to content

Instantly share code, notes, and snippets.

@tejo
Created February 17, 2012 10:50
Show Gist options
  • Save tejo/1852627 to your computer and use it in GitHub Desktop.
Save tejo/1852627 to your computer and use it in GitHub Desktop.
bmfetch
require 'net/http'
require 'uri'
require 'nokogiri'
require 'json'
url = URI.parse('http://www.bikemi.com/localizaciones/localizaciones.php')
res = Net::HTTP.start(url.host, url.port) {|http|
http.get('/localizaciones/localizaciones.php')
}
locations = []
html = Nokogiri::HTML(res.body.scan(/exml\.parseString\(\'(.*?)\'\)\;/)[0][0])
html.css('placemark').each do |pm|
stand = {}
data = pm.css('description div')
stand[:bikes] = data[2].children[0]
stand[:stands] = data[2].children[2]
stand[:address] = data[0].content
pm.css('point coordinates').each do |ll|
stand[:ll] = ll.content
end
locations << stand
end
puts locations.to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment