java 如何使用 MaxMind 的 GeoIP 数据库来确定位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14746169/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 17:14:58  来源:igfitidea点击:

How do I use MaxMind's GeoIP database to determine location?

javageolocationlocationinet

提问by Little Child

So, I was told in my previous question that I can use the databases provided by MaxMindto determine locations.

所以,我在上一个问题中被告知我可以使用MaxMind 提供数据库来确定位置。

So, I got their databases downloaded from their site. They are csvfiles and open up in Excel.

所以,我从他们的网站下载了他们的数据库。它们是csv文件并在 Excel 中打开。

InetAddress ip = InetAddress.getLocalHost()is how I get the IP of my computer. From there I do String justIP = ip.getHostAddress()

InetAddress ip = InetAddress.getLocalHost()是我如何获得我的电脑的IP。从那里我做String justIP = ip.getHostAddress()

My question is:

我的问题是:

  • How do I resolve justIPto a city location using the DB I just downloaded ???
  • 如何justIP使用我刚下载的数据库解析到城市位置???



  • 我对此很陌生,因此将不胜感激。

    One of the files has three columns. startIPNum, endIPNumand locIDI do not know what these do but I guess locIDmaps to a city and country location in the other file.

    其中一个文件具有三列。startIPNumendIPNumlocID我不知道这些做的,但我想locID映射到另一个文件中的城市和国家的位置。

    回答by Fusselchen

    Did you tried the Java examples from Maxmind? http://dev.maxmind.com/geoip/downloadable#Java-8
    And see http://dev.maxmind.com/geoip/csvfor field descriptions

    您是否尝试过 Maxmind 的 Java 示例?http://dev.maxmind.com/geoip/downloadable#Java-8有关字段说明
    ,请参阅http://dev.maxmind.com/geoip/csv