lookupip 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lookupip/v4.rb +16 -8
- data/lib/lookupip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df41fbd9ab23aef2864f89e387d68297e4db6e80
|
4
|
+
data.tar.gz: c9150cb9ebff076f494a10d8eb6f0141ce580976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99178c47c07ac3f749c379175dd5965dafe25f05302cb90c94c0877233a71b6b5805bf0f83a20f4343370e04784b74af2739168d02a70b0c32c1661d9b9f290e
|
7
|
+
data.tar.gz: 5bcb2e0b9c887c7f292d117ac282c2effb9156a79d6494accad5b701924f8311474320826126aee91e068a40e3950266ba9812d521fe1576b3017970c758fe51
|
data/lib/lookupip/v4.rb
CHANGED
@@ -1,22 +1,30 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'uri'
|
4
|
-
require 'ostruct'
|
5
4
|
|
6
5
|
module LookupIP
|
7
6
|
class V4
|
7
|
+
attr_reader :ip, :country, :state, :city, :isp
|
8
|
+
def initialize(ip, country, state, city, isp)
|
9
|
+
@ip = ip
|
10
|
+
@country = country
|
11
|
+
@state = state
|
12
|
+
@city = city
|
13
|
+
@isp = isp
|
14
|
+
end
|
15
|
+
|
8
16
|
def self.address(ip)
|
9
17
|
@ip = ip
|
10
18
|
uri = URI("https://www.iplocation.net/?query=#{@ip}&submit=IP+Lookup")
|
11
19
|
page = Net::HTTP.get(uri)
|
12
20
|
page = Nokogiri::HTML(page)
|
13
|
-
@results =
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
@results = LookupIP::V4.new(
|
22
|
+
@ip,
|
23
|
+
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[2]').text.strip,
|
24
|
+
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[3]').text.strip,
|
25
|
+
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[4]').text.strip,
|
26
|
+
page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[2]/tr/td[1]').text.strip
|
27
|
+
)
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
data/lib/lookupip/version.rb
CHANGED