I'm using whois to perform and parse whois queries. The problem is: i need to perform much more. Thousands and thousands. I found async package em-whois, which sounds perfect for me. This is simple addon for whois, which relies on Ruby Fibers and em-synchrony.
My current code to perform whois queries looks like this:
...
c = Whois::Client.new(:timeout => timeout)
r = c.query(domain)
...
After I've installed em-whois, i'm trying to extend this basic example.
My code looks like this now, and still is very slow:
$: << File.dirname(__FILE__) + '/../lib'
require 'em-whois'
EM.synchrony do
domain = ARGV[0] || "github.com"
$i = 0;
$num = 100;
arr = Array.new($num)
# perform all queries
begin
puts("Inside the loop i = #$i" );
$i += 1;
arr[$i] = Whois.whois(domain);
end while $i < $num
$i = 0;
# get all results
begin
$i += 1;
puts "\r#{domain}\n#{"-" * domain.length}"
[:available?, :status, :expires_on].each do |k|
puts "#{k}: #{arr[$i].properties[k]}"
end
end while $i < $num
EM.stop
end
How do i perform batch queries (1k of domains) using async power of whois and em-whois ?
I don't have any experience with ruby before. I'm Python/C/PHP developer. Please help.