Skip to content

Commit

Permalink
add script for importing domains from quackit
Browse files Browse the repository at this point in the history
  • Loading branch information
afeld committed Jun 19, 2014
1 parent df0ec20 commit 317ea14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source "http://rubygems.org"
gem 'public_suffix'

group :development do
gem "nokogiri", "~> 1.5"
gem "rake", "~> 10.0"
gem "rdoc", "~> 3.12"
gem "bundler", "~> 1.5"
Expand Down
28 changes: 27 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,30 @@ task :add, :sld, :tld, :name do |t, args|
puts "commit failed"
end
end
end
end

task :quackit_import do
require 'nokogiri'
require 'open-uri'
require_relative File.join('lib', 'swot', 'academic_tlds')

domains = Set.new
doc = Nokogiri::HTML(open('http://www.quackit.com/domain-names/country_domain_extensions.cfm'))
doc.css('#content li').each do |li|
desc = li.content.split(' - ')[1]
if desc =~ /academic|education|school/i
domain_el = li.at_css('b')
domain = domain_el.content.sub(/\A\./, '')
if domain =~ /\A(\w+\.)*\w+\z/ && !Swot::ACADEMIC_TLDS.include?(domain)
puts "#{domain} - #{desc.strip.gsub(/\s+/, ' ')}"
domains << domain
end
end
end

puts "\nNEW DOMAINS:\n\n"

domains.sort.each do |domain|
puts domain
end
end

0 comments on commit 317ea14

Please sign in to comment.