Find Latitude Longitude using Ip address


Below mentioned way is to get lat long using ip address

It allows 250 requests in a minute

http://ip-api.com

Using Net::HTTP

require 'net/http'

class LatLong
def self.find(remote_ip)
Proc.new{
   url = URI.parse("http://ip-api.com/json/#{remote_ip}")
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port) {|http|
   http.request(req)
}
JSON.parse res.body
}
end
end


Using open-uri

// Open URI way

require 'open-uri'

# Class for writing all the custom geocoding related code
class LatLong
# method for finding the ip address related details
def self.find(remote_ip)
Proc.new{
res = open(url).read
JSON.parse res
}
end
end



Post a Comment

8 comments:

  1. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also
    Transparent stickers

    ReplyDelete
  2. I am certainly making the most of your site. You unquestionably have some extraordinary knowledge and incredible stories.
    embossed stickers

    ReplyDelete
  3. I always appreciate quality content, Thanks to you for sharing such post.
    Ask Questions Get Answers

    ReplyDelete
  4. Hi! Great work. I feel nice to be here reading your authentic work.
    Custom Sticker

    ReplyDelete


  5. 192.168.0.1

    192.168.1.1

    router login
    Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now,

    ReplyDelete