Created
January 23, 2012 15:02
-
-
Save salvianoo/1663548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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