Created
September 25, 2013 09:34
-
-
Save cieux1/6697284 to your computer and use it in GitHub Desktop.
gem whois example
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
| require 'whois' | |
| def get_whois_info(domains) | |
| domains.each do |domain| | |
| r = Whois::query(domain) | |
| t = r.technical_contacts | |
| begin | |
| puts "#{domain}, #{t[0].email}, #{t[0].name}" | |
| rescue => e | |
| puts "#{domain}, #{e}" | |
| end | |
| sleep 50 + rand(20) | |
| end | |
| end | |
| def extract_domains(urls) | |
| arr = [] | |
| urls.each do |url| | |
| arr << $1 if url =~ /^(.*?)\// | |
| end | |
| puts arr.uniq.size | |
| arr.uniq | |
| end | |
| urls = ["foo.com/aaa/", "baa.com/bbb"] | |
| get_whois_info(extract_domains(urls)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment