8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/lookupip/v4.rb', line 8
def self.address(ip)
@ip = ip
uri = URI("https://www.iplocation.net/?query=#{@ip}&submit=IP+Lookup")
page = Net::HTTP.get(uri)
page = Nokogiri::HTML(page)
@results = OpenStruct.new({
ip: @ip,
country: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[2]').text.strip,
state: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[3]').text.strip,
city: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[1]/tr/td[4]').text.strip,
isp: page.xpath('//*[@id="wrapper"]/section/div/div/div[1]/div[8]/div/table/tbody[2]/tr/td[1]').text.strip
})
end
|