Permalink
Browse files

Merge pull request #168 from bramp/whois.networksolutions.com

Added a parser for whois.networksolution.com.
  • Loading branch information...
2 parents 8c1b2ab + 515e475 commit a7c16c3e38575db821e495ab4da8b9415ce0f31f @weppos committed Jun 5, 2012
@@ -0,0 +1,153 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/base'
+
+
+module Whois
+ class Record
+ class Parser
+
+ # Parser for the whois.networksolutions.com server.
+ #
+ # @note This parser is just a stub and provides only a few basic methods
+ # to check for domain availability and get domain status.
+ # Please consider to contribute implementing missing methods.
+ #
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
+ #
+ # @author Andrew Brampton <me@bramp.net>
+ #
+ class WhoisNetworksolutionsCom < Base
+
+ property_not_supported :status
+
+ # The server is contacted only in case of a registered domain.
+ property_supported :available? do
+ false
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+ property_supported :registrar do
+ Record::Registrar.new(
+ :name => 'Network Solutions',
+ :organization => 'Network Solutions, LLC',
+ :url => 'http://www.networksolutions.com/'
+ )
+ end
+
+ property_supported :created_on do
+ if content_for_scanner =~ /Record created on (.+)\.\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :updated_on do
+ if content_for_scanner =~ /Database last updated on (.+)\.\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :expires_on do
+ if content_for_scanner =~ /Record expires on (.+)\.\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :registrant_contacts do
+ build_contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
+ end
+
+ property_supported :admin_contacts do
+ build_contact('Administrative Contact', Record::Contact::TYPE_ADMIN)
+ end
+
+ property_supported :technical_contacts do
+ build_contact('Technical Contact', Record::Contact::TYPE_TECHNICAL)
+ end
+
+
+ property_supported :nameservers do
+ if content_for_scanner =~ /Domain servers in listed order:\n\n((?:[^\n]+\n)+)/
+ $1.split("\n").map do |line|
+ # NS01.XIF.COM 63.240.200.70
+ dns = line.strip.split(" ")
+ Record::Nameserver.new(dns[0].downcase, dns[1])
+ end
+ end
+ end
+
+
+ private
+
+ def build_contact(element, type)
+ match = content_for_scanner.slice(/#{element}.*\n((.+\n){4,7})/, 1)
+ return unless match
+
+ lines = match.split("\n").map(&:strip)
+
+ # 0 XIF Communications | mpowers LLC
+ # 1 1200 New Hampshire Avenue NW | 21010 Southbank St #575
+ # 2 Suite 410 | Potomac Falls, VA 20165
+ # 3 Washington, DC 20036 | US
+ # 4 US
+
+ # 0 Communications, XIF ContactMiddleName noc@xif.com | mpowers LLC michael@mpowers.net
+ # 1 XIF Communications | 21010 Southbank St #575
+ # 2 1200 New Hampshire Avenue NW | Potomac Falls, VA 20165
+ # 3 Suite 410 | US
+ # 4 Washington, DC 20036 | +1.5712832829
+ # 5 US
+ # 6 202-463-7200 fax: 202-318-4003
+
+ # Does the first line end in something that looks like a email address?
+ if lines[0].to_s =~ /\S+@\S+$/
+ # The record has a extra name and number line
+ name, email = lines.shift.scan(/^(.+)\s(\S+@\S+)$/).first
+ name = name.strip
+ end
+
+ # Does the last line contains the word fax, or has >9 digits
+ if lines[-1].to_s =~ / fax: /
+ phone, fax = lines.pop.to_s.scan(/^(.+) fax: (.+)$/).first
+ phone = phone.strip
+ fax = fax.strip
+
+ elsif lines[-1].to_s.gsub(/[^\d]+/, '').length > 9
+ phone = lines.pop
+ end
+
+ country_code = lines.pop
+ city, state, zip = lines.pop.scan(/^(.+), ([A-Z]{2}) ([\sA-Z0-9\-]+)$/).first
+ organization = lines.shift if lines.length >= 2
+
+ address = lines.join("\n")
+
+ Record::Contact.new(
+ :type => type,
+ :name => name,
+ :organization => organization,
+ :address => address,
+ :city => city,
+ :state => state,
+ :zip => zip,
+ :country_code => country_code,
+ :email => email,
+ :phone => phone,
+ :fax => fax
+ )
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,47 @@
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].organization == "mpowers LLC"
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
+
+#admin_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
+ should: %s[0].name == "mpowers LLC"
+ should: %s[0].organization == nil
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5712832829"
+ should: %s[0].fax == nil
+ should: %s[0].email == "michael@mpowers.net"
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].name == "mpowers LLC"
+ should: %s[0].organization == nil
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5712832829"
+ should: %s[0].fax == nil
+ should: %s[0].email == "michael@mpowers.net"
@@ -0,0 +1,21 @@
+
+Registrant:
+mpowers LLC
+ 21010 Southbank St #575
+ Potomac Falls, VA 20165
+ US
+
+ Domain Name: APPTAP.COM
+
+ ------------------------------------------------------------------------
+ Promote your business to millions of viewers for only $1 a month
+ Learn how you can get an Enhanced Business Listing here for your domain name.
+ Learn more at http://www.NetworkSolutions.com/
+ ------------------------------------------------------------------------
+
+ Administrative Contact, Technical Contact:
+ mpowers LLC michael@mpowers.net
+ 21010 Southbank St #575
+ Potomac Falls, VA 20165
+ US
+ +1.5712832829
@@ -0,0 +1,25 @@
+NOTICE AND TERMS OF USE: You are not authorized to access or query our WHOIS
+database through the use of high-volume, automated, electronic processes. The
+Data in Network Solutions' WHOIS database is provided by Network Solutions for information
+purposes only, and to assist persons in obtaining information about or related
+to a domain name registration record. Network Solutions does not guarantee its accuracy.
+By submitting a WHOIS query, you agree to abide by the following terms of use:
+You agree that you may use this Data only for lawful purposes and that under no
+circumstances will you use this Data to: (1) allow, enable, or otherwise support
+the transmission of mass unsolicited, commercial advertising or solicitations
+via e-mail, telephone, or facsimile; or (2) enable high volume, automated,
+electronic processes that apply to Network Solutions (or its computer systems). The
+compilation, repackaging, dissemination or other use of this Data is expressly
+prohibited without the prior written consent of Network Solutions. You agree not to use
+high-volume, automated, electronic processes to access or query the WHOIS
+database. Network Solutions reserves the right to terminate your access to the WHOIS
+database in its sole discretion, including without limitation, for excessive
+querying of the WHOIS database or for failure to otherwise abide by this policy.
+Network Solutions reserves the right to modify these terms at any time.
+
+Get a FREE domain name registration, transfer, or renewal with any annual hosting package.
+
+http://www.networksolutions.com
+
+No match for "BLAHBLAHBLAH.COM".
+
@@ -0,0 +1,90 @@
+#status
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#available?
+ should: %s == false
+
+#registered?
+ should: %s == true
+
+
+#created_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("1997-06-10")
+
+#updated_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2012-05-27 22:19:52 EDT")
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2014-06-09")
+
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.name == 'Network Solutions'
+ should: %s.organization == 'Network Solutions, LLC'
+ should: %s.url == 'http://www.networksolutions.com/'
+
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].name == nil
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
+
+#admin_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
+ should: %s[0].name == "Communications, XIF ContactMiddleName"
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "202-463-7200"
+ should: %s[0].fax == "202-318-4003"
+ should: %s[0].email == "noc@xif.com"
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].name == "Communications, XIF ContactMiddleName"
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "202-463-7200"
+ should: %s[0].fax == "202-318-4003"
+ should: %s[0].email == "noc@xif.com"
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(3)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "ns01.xif.com"
+ should: %s[0].ipv4 == "63.240.200.70"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "ns-east.cerf.net"
+ should: %s[1].ipv4 == "207.252.96.3"
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "ns-west.cerf.net"
+ should: %s[2].ipv4 == "192.153.156.3"
Oops, something went wrong.

0 comments on commit a7c16c3

Please sign in to comment.