Class: Ryo::Plugin::Whois

Inherits:
Object
  • Object
show all
Defined in:
lib/ryo/plugin/whois.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#domainObject (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

#discoverObject



57
58
59
# File 'lib/ryo/plugin/whois.rb', line 57

def discover
  parse
end

#docObject



20
21
22
# File 'lib/ryo/plugin/whois.rb', line 20

def doc
  @doc ||= Oga.parse_html(fetch_body)
end

#endpointObject



11
12
13
# File 'lib/ryo/plugin/whois.rb', line 11

def endpoint
  "https://domainbigdata.com"
end

#fetch_bodyObject



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_statsObject



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

#parseObject



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

#registrantObject



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