我正在用 Ruby 编写一个简单的程序来检查是否使用了域列表。基本上它循环遍历一个列表,并使用以下函数进行检查。
require 'rubygems'
require 'whois'
def check_domain(domain)
c = Whois::Client.new
c.query("google.com").available?
end
该程序不断出错(即使我在 google.com 中硬编码),并打印下面的消息。鉴于该程序非常简单,我已经没有什么想法了——有什么建议吗?
/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:165:in `query_the_socket': Errno::ECONNRESET: Connection reset by peer (Whois::ConnectionError)
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/verisign.rb:41:in `request'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:113:in `query'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:150:in `buffer_start'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.rb:112:in `query'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/client.rb:90:in `query'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'
from /Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/client.rb:87:in `query'
from checker.rb:7:in `check_domain'
from checker.rb:14
from checker.rb:11:in `each'
from checker.rb:11