Skip to content

Instantly share code, notes, and snippets.

@salvianoo
Created January 23, 2012 15:02
Show Gist options
  • Save salvianoo/1663548 to your computer and use it in GitHub Desktop.
Save salvianoo/1663548 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
url = 'http://pt.wikipedia.org/wiki/Anexo:Lista_de_munic%C3%ADpios_do_Brasil'
doc = Nokogiri::HTML open url
xml_file = "cities.xml"
File.delete xml_file if File.exists? xml_file
file = File.new xml_file, "w"
doc.xpath('//td/ul/li').each do |link|
file.write link.content + "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment