Movatterモバイル変換


[0]ホーム

URL:


Ruby Whois

Donate a coffee to support the development.

We accept Bitcoin (BTC) and Ethereum (ETH) donations.

Whois is an intelligent — pure Ruby —WHOIS client and parser.

It provides a flexible and programmable API to query WHOIS servers and look up IP, TLD, and domain WHOIS information. It also offers command-line interface to run WHOIS queries from the console.

Whois was extracted fromRoboWhois andRoboDomain, and it's now in use atDNSimple. It has been performing queries in production since July 2009.

Features

  • Ability to lookup WHOIS record forIPv4, IPv6, TLDs, and ICANN new gTLDs
  • Ability toparse WHOIS responses
  • Flexible and extensible interface (e.g. You can definecustom servers on the fly)
  • Object oriented design, featuring 10 different design patterns
  • Pure Ruby library, without any external dependency other than Ruby itself
  • Successfully tested against different Ruby implementations, including Ruby and JRuby

Install

You can install the gem manually viaRubyGems:

$ gem install whois

Or useBundler and define it as a dependency in yourGemfile:

gem 'whois', '~> 4.0'

Upgrade

Install the newer version via RubyGems:

$ gem install whois

TheCHANGELOG file contains a detailed list of all the changes, grouped by version.

This library is versioned using the rules ofSemantic Versioning.

Getting Started

This section covers the essentials of theWhois library. For a more deep explanation visit the completeusage section or read thewhois manual.

Querying a WHOIS

This is the simplest way to send a WHOIS request is using the#lookup method.

c=Whois::Client.newc.lookup("google.com")# => #<Whois::Record>

The method returns aWhois::Record instance which essentially looks and behaves like aString but it's way more powerful than a string (seeConsuming the Record).

You can print, compare and modify it exactly as a string.

c=Whois::Client.newr=c.lookup("google.com")putsr# the full whois record response# ...# ...

If you don't need to customize theWhois::Client, you can also use theWhois.whois shortcut (seeWhois::Client shortcuts section for more information).

r=Whois.whois("google.com")putsr# the full whois record response# ...# ...

Whois provides the ability to get WHOIS information for TLDs, domain names, IPv4 and IPv6 IP addresses. The client is smart enough to guess the best WHOIS server according to given query, send the request and return the response.

c=Whois::Client.new# Domain WHOISc.lookup("google.com")# => #<Whois::Record ...># TLD WHOISc.lookup(".com")# => #<Whois::Record ...># IPv4 WHOISc.lookup("74.125.67.100")# => #<Whois::Record ...># IPv6 WHOISc.lookup("2001:db8::1428:57ab")# => #<Whois::Record ...>

Consuming the Record

Any WHOIS query returns aWhois::Record. This object looks like a String, but it's way more powerful.

TheWhois::Record encapsulates a WHOIS record and provides the ability to parse the WHOIS response programmatically, by using an object oriented syntax. Yep, you're not dreaming: no more regular expressions!

r=Whois.whois("google.it")# => #<Whois::Record ...>r.available?# => falser.registered?# => truer.created_on# => Fri Dec 10 00:00:00 +0100 1999t=r.technical_contact# => #<Whois::Record::Contact ...>t.id# => "TS7016-ITNIC"t.name# => "Technical Services"r.nameservers.eachdo|nameserver|putsnameserverend

This feature is made possible by theWhois::Record::Parser. Unfortunately, due to the lack of a global standard, each WHOIS server requires a specific parser. For this reason, the library doesn't currently support all existing WHOIS servers.

If you create a new parser, please consider releasing it to the public so that it can be included in a next version.

More Information

Copyright (c) 2009-2018Simone Carletti. This is Free Software distributed under theMIT license.


[8]ページ先頭

©2009-2025 Movatter.jp