Class: Ryo::Plugin::Whois
- Inherits:
-
Object
- Object
- Ryo::Plugin::Whois
- Defined in:
- lib/ryo/plugin/whois.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
Class Method Summary collapse
Instance Method Summary collapse
- #discover ⇒ Object
- #doc ⇒ Object
- #endpoint ⇒ Object
- #fetch_body ⇒ Object
- #globa_stats ⇒ Object
-
#initialize(domain) ⇒ Whois
constructor
A new instance of Whois.
- #parse ⇒ Object
- #registrant ⇒ Object
Constructor Details
#initialize(domain) ⇒ Whois
Returns a new instance of Whois.
7 8 9 |
# File 'lib/ryo/plugin/whois.rb', line 7 def initialize(domain) @domain = domain end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/ryo/plugin/whois.rb', line 6 def domain @domain end |
Class Method Details
.discover(domain) ⇒ Object
61 62 63 |
# File 'lib/ryo/plugin/whois.rb', line 61 def self.discover(domain) new(domain).discover end |
Instance Method Details
#discover ⇒ Object
57 58 59 |
# File 'lib/ryo/plugin/whois.rb', line 57 def discover parse end |
#doc ⇒ Object
20 21 22 |
# File 'lib/ryo/plugin/whois.rb', line 20 def doc @doc ||= Oga.parse_html(fetch_body) end |
#endpoint ⇒ Object
11 12 13 |
# File 'lib/ryo/plugin/whois.rb', line 11 def endpoint "https://domainbigdata.com" end |
#fetch_body ⇒ Object
15 16 17 18 |
# File 'lib/ryo/plugin/whois.rb', line 15 def fetch_body res = Client.http.get("#{endpoint}/#{domain}") res.body.to_s end |
#globa_stats ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ryo/plugin/whois.rb', line 31 def globa_stats h = {} h[:title] = doc.at_css("#trTitle > td:nth-child(2)")&.text h[:date_creation] = doc.at_css("#trDateCreation > td:nth-child(2)")&.text h[:date_creation] = doc.at_css("#trDateCreation > td:nth-child(2)")&.text h[:web_age] = doc.at_css("#trWebAge > td:nth-child(2)")&.text h[:ip] = doc.at_css("#trIP > td:nth-child(2)")&.text h[:ip_geolocation] = doc.at_css("#trIPGeolocation > td:nth-child(2)")&.text&.strip h.compact end |
#parse ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ryo/plugin/whois.rb', line 24 def parse h = {} h[:globa_stats] = globa_stats h[:registrant] = registrant h end |
#registrant ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ryo/plugin/whois.rb', line 42 def registrant h = {} h[:name] = doc.at_css("#trRegistrantName > td:nth-child(2) > a")&.text h[:organization] = doc.at_css("#MainMaster_trRegistrantOrganization > td:nth-child(2) > a")&.text h[:email] = doc.at_css("#trRegistrantEmail > td:nth-child(2)")&.text h[:address] = doc.at_css("#trRegistrantAddress > td:nth-child(2)")&.text h[:city] = doc.at_css("#trRegistrantCity > td:nth-child(2)")&.text h[:state] = doc.at_css("#trRegistrantState > td:nth-child(2)")&.text h[:country] = doc.at_css("#trRegistrantCountry > td:nth-child(2)")&.text h[:phone] = doc.at_css("#trRegistrantTel > td:nth-child(2)")&.text h[:fax] = doc.at_css("#trRegistrantFax > td:nth-child(2)")&.text h[:private] = doc.at_css("#MainMaster_divRegistrantIDCard > div:nth-child(4) > table > tbody > tr:nth-child(10) > td:nth-child(2)")&.text h.compact end |