Last active
August 29, 2015 14:22
-
-
Save lcguida/cb791613e3ae2df654ae to your computer and use it in GitHub Desktop.
Universities Worldwide to YAML (Converts all information from http://univ.cc to a YAML file)
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 'open-uri' | |
require 'nokogiri' | |
require 'yaml' | |
start = 1 | |
INCREMENT = 50 | |
has_more = true | |
File.open('universities.yml', 'w') do |file| | |
while has_more do | |
doc = Nokogiri::HTML(open("http://univ.cc/search.php?dom=world&start=#{start}")) | |
list = doc.css('.fixedWidth ol li a') | |
has_more = false unless list.any? | |
list.each do |item| | |
university = { name: item.text, url: item.attr('href') } | |
file.puts university.to_yaml | |
end | |
start += INCREMENT | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment