Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

New GoDaddy parser and fix issue 103 #105

Closed
wants to merge 4 commits into from

2 participants

@pmyteh

I've written a simple parser for responses from whois.godaddy.com, the single largest .com registry. Their format for addresses is depressingly irregular (may be missing the organization and/or telephone/fax number lines, without the helpful field: data format given by some other registries) but it works pretty well and adds parseability to ~30% of all .coms.

Issue #103 is also fixed by a separate small commit.

Thanks,
Tom

@weppos
Owner

Hi Tom,

thank you very much for the parser. Unfortunately, I cannot merge the pull request without a test suite.
Would it be possible to provide it?

Creating a test suite for a parser is just easy as extracting some fixtures and creating a .expected file.
See for example bfbd27b or 8218ebb

@weppos
Owner

I merged your fix for issue #103

@weppos weppos was assigned
@pmyteh

Sorry - I'm rather new to this. I'll have a look and put something together.

@pmyteh

Hope that's sufficient. Like whois.markmonitor.com, the server really shouldn't be queried unless the domain is registered. If there's something else I'm missing, do let me know: I'd like to get this right.

@weppos
Owner

Thanks @pmyteh. Once you create the tests, you should also run

$ rake genspec:parser

to generate the test suites and then run

$ rake

to execute them. I executed the test suite and one test fails.

1) Whois::Record::Parser::WhoisGodaddyCom status_registered.expected#registrant_contacts 
   Failure/Error: @parser.registrant_contacts[0].email.should        == ""
     expected: ""
          got: nil (using ==)
   # ./spec/whois/record/parser/responses/whois.godaddy.com/status_registered_spec.rb:80:in `block (3 levels) in <top (required)>'

The rest of the patch is ok for me.

@weppos weppos closed this in fae71f9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 31, 2011
  1. Add new whois.godaddy.com parser

    Tom Nicholls authored
  2. Fix issue #103: minor error in Verisign adapter

    Tom Nicholls authored
Commits on Aug 4, 2011
  1. @pmyteh
  2. @pmyteh
This page is out of date. Refresh to see the latest.
View
130 lib/whois/record/parser/whois.godaddy.com.rb
@@ -0,0 +1,130 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2011 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/base'
+
+
+module Whois
+ class Record
+ class Parser
+
+ #
+ # = whois.godaddy.com parser
+ #
+ # Parser for the whois.godaddy.com server.
+ # Contributed by Tom Nicholls <tom.nicholls@oii.ox.ac.uk>
+ #
+ #
+ # 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 WhoisNicIt parser for an explanation of all available methods
+ # and examples.
+ #
+
+ class WhoisGodaddyCom < Base
+
+ property_not_supported :status
+
+ # The server seems to provide only information for registered domains
+ property_supported :available? do
+ false
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+ property_supported :created_on do
+ if content_for_scanner =~ /Created on: (.+)\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :updated_on do
+ if content_for_scanner =~ /Last Updated on: (.+)\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :expires_on do
+ if content_for_scanner =~ /Expires on: (.+)\n/
+ Time.parse($1)
+ end
+ end
+
+
+ property_supported :registrar do
+ Record::Registrar.new(
+ :name => content_for_scanner[/Registered through: (.+) \(/, 1],
+ :url => content_for_scanner[/Registered through: .*\((.+)\)\n/, 1]
+ )
+ end
+
+
+ property_supported :registrant_contacts do
+ contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
+ end
+
+ property_supported :admin_contacts do
+ contact('Administrative Contact:', Record::Contact::TYPE_ADMIN)
+ end
+
+ property_supported :technical_contacts do
+ contact('Technical Contact:', Record::Contact::TYPE_TECHNICAL)
+ end
+
+ property_supported :nameservers do
+ content_for_scanner[/Domain servers in listed order:\n((?:\s*[^\s\n]+\n)+)\n\s*\n/, 1].split("\n").map do |line|
+ Record::Nameserver.new(line.strip)
+ end
+ end
+
+
+ private
+
+
+ def contact(element, type)
+ info = content_for_scanner[/#{element}\n((.+\n)+)\n/, 1].to_s.split("\n").map(&:strip)
+ # NB: Lines 1 and 5 may be absent, depending on the record.
+ # The parser attempts to correct for this, but may be a bit flaky
+ # on non-standard data.
+ # 0 GoDaddy.com, Inc., GoDaddy.com, Inc. dns@jomax.net
+ # 1 GoDaddy.com, Inc.
+ # 2 14455 N Hayden Rd Suite 219
+ # 3 Scottsdale, Arizona 85260
+ # 4 United States
+ # 5 +1.4805058800 Fax -- +1.4805058844
+ phone = ""
+ fax = ""
+ if info[-1].to_s =~ /Fax --/
+ phone, fax = info.delete_at(-1).to_s.scan(/^(.*) Fax --(.*)$/).first
+ phone = phone.strip
+ fax = fax.strip
+ end
+ Record::Contact.new(
+ :type => type,
+ :name => info[0].to_s.gsub(/\s\S+@[^\.].*\.[a-z]{2,}\s?\)?$/, "").strip,
+ :organization => info.length >= 5 ? info[-4] : "",
+ :address => info.length >= 4 ? info[-3] : "",
+ :city => info.length >= 4 ? info[-2].to_s.partition(",")[0] : "",
+ :state => info.length >= 4 ? info[-2].to_s.partition(",")[2].rpartition(" ")[0].to_s.strip : "",
+ :zip => info.length >= 4 ? info[-2].to_s.rpartition(" ")[2] : "",
+ :country_code => info.length >= 4 ? info[-1] : "",
+ :email => info[0].to_s.scan(/[^\s]\S+@[^\.].*\.[a-z]{2,}[^\s\)\n]/).first,
+ :phone => phone,
+ :fax => fax
+ )
+ end
+
+ end
+
+ end
+ end
+end
View
2  lib/whois/server/adapters/verisign.rb
@@ -49,7 +49,7 @@ def request(string)
def extract_referral(response)
if response =~ /Domain Name:/
endpoint = response.scan(/Whois Server: (.+?)$/).flatten.last
- endpoint.strip!
+ endpoint.strip! if endpoint != nil
endpoint = nil if endpoint == "not defined"
endpoint
end
View
86 spec/fixtures/responses/whois.godaddy.com/status_registered.expected
@@ -0,0 +1,86 @@
+#status
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#available?
+ should: %s == false
+
+#registered?
+ should: %s == true
+
+#created_on
+ should: %s be_a(Time)
+ should: %s == Time.parse("02-Mar-99")
+
+#updated_on
+ should: %s be_a(Time)
+ should: %s == Time.parse("21-Oct-10")
+
+#expires_on
+ should: %s be_a(Time)
+ should: %s == Time.parse("02-Mar-19")
+
+
+#registrar
+ should: %s be_a(_registrar)
+ should: %s.id == nil
+ should: %s.name == "GoDaddy.com, Inc."
+ should: %s.url == "http://www.godaddy.com"
+
+#registrant_contacts
+ should: %s be_a(Array)
+ should: %s have(1).items
+ should: %s[0] be_a(_contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].name == "GoDaddy.com, Inc."
+ should: %s[0].organization == ""
+ should: %s[0].address == "14455 N Hayden Rd Suite 219"
+ should: %s[0].city == "Scottsdale"
+ should: %s[0].zip == "85260"
+ should: %s[0].state == "Arizona"
+ should: %s[0].country_code == "United States"
+ should: %s[0].phone == ""
+ should: %s[0].fax == ""
+ should: %s[0].email == ""
+
+#admin_contacts
+ should: %s be_a(Array)
+ should: %s have(1).items
+ should: %s[0] be_a(_contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
+ should: %s[0].name == "GoDaddy.com, Inc., GoDaddy.com, Inc."
+ should: %s[0].organization == "GoDaddy.com, Inc."
+ should: %s[0].address == "14455 N Hayden Rd Suite 219"
+ should: %s[0].city == "Scottsdale"
+ should: %s[0].zip == "85260"
+ should: %s[0].state == "Arizona"
+ should: %s[0].country_code == "United States"
+ should: %s[0].phone == "+1.4805058800"
+ should: %s[0].fax == "+1.4805058844"
+ should: %s[0].email == "dns@jomax.net"
+
+#technical_contacts
+ should: %s be_a(Array)
+ should: %s have(1).items
+ should: %s[0] be_a(_contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].name == "GoDaddy.com, Inc., GoDaddy.com, Inc."
+ should: %s[0].organization == "GoDaddy.com, Inc."
+ should: %s[0].address == "14455 N Hayden Rd Suite 219"
+ should: %s[0].city == "Scottsdale"
+ should: %s[0].zip == "85260"
+ should: %s[0].state == "Arizona"
+ should: %s[0].country_code == "United States"
+ should: %s[0].phone == "+1.4805058800"
+ should: %s[0].fax == "+1.4805058844"
+ should: %s[0].email == "dns@jomax.net"
+
+
+#nameservers
+ should: %s be_a(Array)
+ should: %s have(3).items
+ should: %s[0] be_a(_nameserver)
+ should: %s[0] == _nameserver.new(:name => "CNS1.SECURESERVER.NET")
+ should: %s[1] be_a(_nameserver)
+ should: %s[1] == _nameserver.new(:name => "CNS2.SECURESERVER.NET")
+ should: %s[2] be_a(_nameserver)
+ should: %s[2] == _nameserver.new(:name => "CNS3.SECURESERVER.NET")
View
60 spec/fixtures/responses/whois.godaddy.com/status_registered.txt
@@ -0,0 +1,60 @@
+The data contained in GoDaddy.com, Inc.'s WhoIs database,
+while believed by the company to be reliable, is provided "as is"
+with no guarantee or warranties regarding its accuracy. This
+information is provided for the sole purpose of assisting you
+in obtaining information about domain name registration records.
+Any use of this data for any other purpose is expressly forbidden without the prior written
+permission of GoDaddy.com, Inc. By submitting an inquiry,
+you agree to these terms of usage and limitations of warranty. In particular,
+you agree not to use this data to allow, enable, or otherwise make possible,
+dissemination or collection of this data, in part or in its entirety, for any
+purpose, such as the transmission of unsolicited advertising and
+and solicitations of any kind, including spam. You further agree
+not to use this data to enable high volume, automated or robotic electronic
+processes designed to collect or compile this data for any purpose,
+including mining this data for your own personal or commercial purposes.
+
+Please note: the registrant of the domain name is specified
+in the "registrant" field. In most cases, GoDaddy.com, Inc.
+is not the registrant of domain names listed in this database.
+
+
+Registrant:
+ GoDaddy.com, Inc.
+ 14455 N Hayden Rd Suite 219
+ Scottsdale, Arizona 85260
+ United States
+
+ Registered through: GoDaddy.com, Inc. (http://www.godaddy.com)
+ Domain Name: GODADDY.COM
+ Created on: 02-Mar-99
+ Expires on: 02-Mar-19
+ Last Updated on: 21-Oct-10
+
+ Administrative Contact:
+ GoDaddy.com, Inc., GoDaddy.com, Inc. dns@jomax.net
+ GoDaddy.com, Inc.
+ 14455 N Hayden Rd Suite 219
+ Scottsdale, Arizona 85260
+ United States
+ +1.4805058800 Fax -- +1.4805058844
+
+ Technical Contact:
+ GoDaddy.com, Inc., GoDaddy.com, Inc. dns@jomax.net
+ GoDaddy.com, Inc.
+ 14455 N Hayden Rd Suite 219
+ Scottsdale, Arizona 85260
+ United States
+ +1.4805058800 Fax -- +1.4805058844
+
+ Domain servers in listed order:
+ CNS1.SECURESERVER.NET
+ CNS2.SECURESERVER.NET
+ CNS3.SECURESERVER.NET
+
+
+ ****************************************************
+ See Business Registration Listing
+ ****************************************************
+ Copy and paste the link below to view additional details:
+ http://who.godaddy.com/whoischeck.aspx?domain=GODADDY.COM
Something went wrong with that request. Please try again.