Я новичок в Rails и хотел попробовать жемчужину Ruby 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 precision64) с Rails 4.0 и Ruby версии 2.1.2. Веб-сервер — это Webrick по умолчанию.
Все, что я хотел бы сделать, это получить объект <Whois::Record>
и извлечь из него значения, такие как домен, domain_id, регистратор и т. д.... какие-нибудь советы?