Skip to content

Instantly share code, notes, and snippets.

@streetcarmonkey
Created December 24, 2014 05:03
Show Gist options
  • Save streetcarmonkey/58bfeab8e40043ffbb4b to your computer and use it in GitHub Desktop.
Save streetcarmonkey/58bfeab8e40043ffbb4b to your computer and use it in GitHub Desktop.
Simple Ruby whois email parser, no gems used.
RE = /[\w.!#\$%+-]+@[\w-]+(?:\.[\w-]+)+/
def simple_whois_email_extractor(domain = 'DISNEY.COM')
puts "Getting whois info for #{domain.downcase}"
emails = Array.new
IO.popen("whois #{domain.downcase}") do |io|
string = ''
while (line = io.gets) do
string += line
end
string.scan(RE).each do | email | emails.push email end
end
emails.uniq!
return emails
end
emails = simple_whois_email_extractor #'PIXAR.com'
puts emails.size
emails.each do | email | puts email end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment