Skip to content

Instantly share code, notes, and snippets.

@nmarley
Last active Aug 29, 2015
Embed
What would you like to do?
Domain Expiration Checker
#! /usr/bin/env ruby
require 'whois'
require 'date'
require 'time'
require 'pp'
require 'awesome_print'
class Chequer
def initialize
@whois_client = Whois::Client.new
end
def lookup_domain(domain)
record = @whois_client.lookup(domain)
record
end
def expires_on(domain)
lookup_domain(domain).expires_on
end
end
c = Chequer.new
# one domain on each line, trim whitespace, filter empty lines
domain_list = File.read('domains.txt')
.split("\n")
.grep(/./)
.map { |d| d.gsub(/^\s+|\s+$/, '') }
domain_list.each do |domain|
# whenn should be a 'Time' object
whenn = c.expires_on(domain)
puts "#{domain} #{whenn}"
end
ngmarley.com
nathanmarley.com
maidinnwa.com
jasminedragontea.com
stateofthecrypto.com
marley.io
blackcarrot.be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment