Created
December 24, 2014 05:03
-
-
Save streetcarmonkey/58bfeab8e40043ffbb4b to your computer and use it in GitHub Desktop.
Simple Ruby whois email parser, no gems used.
This file contains hidden or 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
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