我是Rails的新手,想試試Ruby Whois gem。Whois解析器不工作
我定義了一個創建報告的Active Record記錄。然後,該報告將充滿來自whois查詢的數據(最好被解析)。
當我做查詢時,我得到了一些非常奇怪的東西。我已經使用ByeBug作爲調試器:
$ (byebug) Whois.whois("google.it")
"\n*********************************************************************\n* Please note
that the following result could be a subgroup of *\n* the data contained in the database.
*\n* *\n* Additional
information can be visualized at:
*\n* http://www.nic.it/cgi-bin/Whois/whois.cgi
*\n*********************************************************************\n\nDomain: google.it\nStatus: ok\nCreated: 1999-12-10
00:00:00\nLast Update: 2014-05-07 00:52:45\nExpire Date: 2015-04-21\n
\nRegistrant\n Name: Google Ireland Holdings\n Organization: Google
Ireland Holdings\n ContactID: DUP430692088\n Address: 70 Sir John
Rogersons Quay\n Dublin\n 2\n
IE\n IE\n Created: 2013-04-21 01:05:35\n Last Update:
2013-04-21 01:05:35\n\nAdmin Contact\n Name: Tsao Tu\n Organization: Tu
Tsao\n ContactID: DUP142437129\n Address: 70 Sir John Rogersons
Quay\n Dublin\n 2\n
IE\n IE\n Created: 2013-04-21 01:05:35\n Last Update:
2013-04-21 01:05:35\n\nTechnical Contacts\n Name: Google Ireland Holdings\n
Organization: Google Ireland Holdings\n ContactID: DUP430692088\n
Address: 70 Sir John Rogersons Quay\n
Dublin\n 2\n IE\n IE\n
Created: 2013-04-21 01:05:35\n Last Update: 2013-04-21 01:05:35\n
\nRegistrar\n Organization: MarkMonitor International Limited\n Name:
MARKMONITOR-REG\n Web: https://www.markmonitor.com/\n\nNameservers\n
ns1.google.com\n ns4.google.com\n ns2.google.com\n ns3.google.com\n\n"
$ (byebug) Whois.whois("google.it").parser
#<Whois::Record::Parser:0x000000065bdc30
@record="\n*********************************************************************\n*
Please note that the following result could be a subgroup of *\n* the data contained
in the database.
*\n* *\n* Additional
information can be visualized at: *\n* http://www.nic.it/cgi-bin/Whois
/whois.cgi
*\n*********************************************************************
\n\nDomain: google.it\nStatus: ok\nCreated: 1999-12-10
00:00:00\nLast Update: 2014-05-07 00:52:45\nExpire Date: 2015-04-21\n
\nRegistrant\n Name: Google Ireland Holdings\n Organization: Google
Ireland Holdings\n ContactID: DUP430692088\n Address: 70 Sir John
Rogersons Quay\n Dublin\n 2\n
IE\n IE\n Created: 2013-04-21 01:05:35\n Last Update:
2013-04-21 01:05:35\n\nAdmin Contact\n Name: Tsao Tu\n Organization: Tu
Tsao\n ContactID: DUP142437129\n Address: 70 Sir John Rogersons
Quay\n Dublin\n 2\n
IE\n IE\n Created: 2013-04-21 01:05:35\n Last Update:
2013-04-21 01:05:35\n\nTechnical Contacts\n Name: Google Ireland Holdings\n Organization: Google Ireland Holdings\n ContactID: DUP430692088\n
Address: 70 Sir John Rogersons Quay\n
Dublin\n 2\n IE\n IE\n
Created: 2013-04-21 01:05:35\n Last Update: 2013-04-21 01:05:35\n
\nRegistrar\n Organization: MarkMonitor International Limited\n Name:
MARKMONITOR-REG\n Web: https://www.markmonitor.com/\n\nNameservers\n
ns1.google.com\n ns4.google.com\n ns2.google.com\n ns3.google.com\n\n">
我想知道這一切是關於什麼。它的結構並不像在IRB或簡單的控制檯中那樣。
,當我嘗試看屬性,它只是告訴我走開:
$ (byebug) Whois.whois("google.it").property_supported?(:domain)
NoMethodError Exception: undefined method `property_supported?' for #<Whois::Record:0x000000065aba08>
nil
我在一個虛擬機(Ubuntu的precise64)運行的Rails 4.0和Ruby 2.1.2版。 Web服務器是默認的Webrick。
我想要做的就是獲取對象<Whois::Record>
,並從中提取值,如域名,域名ID,註冊商等等......任何提示?
試圖使代碼可讀,但只有到目前爲止 – 2014-09-30 12:22:46
請花時間使用正確的語法和格式。它使您的問題更容易閱讀,這有助於我們幫助您解決問題。 *不*這樣做只會阻礙潛在的回答者,他們認爲你不夠重視寫一個可讀的問題,所以他們爲什麼要照顧足夠的幫助。 – 2014-09-30 16:14:19