From 317ea1413f0bf56b50129104f48b9426ecbf5d13 Mon Sep 17 00:00:00 2001 From: Aidan Feldman Date: Thu, 19 Jun 2014 00:58:55 -0400 Subject: [PATCH] add script for importing domains from quackit --- Gemfile | 1 + Rakefile | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9c4b589a23..19527e33d9 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Rakefile b/Rakefile index 9fdf50fee7..40d0db3c06 100644 --- a/Rakefile +++ b/Rakefile @@ -61,4 +61,30 @@ task :add, :sld, :tld, :name do |t, args| puts "commit failed" end end -end \ No newline at end of file +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