可靠的市级地理ip,免费本地数据库

时间:2020-12-31 19:18:49

I want to put together a PHP script to resolve city name (nothing else is needed) with a good resolution just for a single country (IRAN). As I have to query the DB for multiple times, its better to go through a downloadable local version. I have read most of posts on * and since now I have tested these:

我想为一个国家(伊朗)编写一个PHP脚本来解析城市名(不需要其他任何东西),并给出一个好的解决方案。由于我不得不多次查询DB,所以最好使用可下载的本地版本。我已经阅读了大多数关于*的文章,从现在开始我已经测试了这些:

  • GeoIP City from maxmind sounds good, but is not free.
  • 来自maxmind的GeoIP City听起来不错,但不是免费的。
  • GeoIP from maxmind, has a low level of accuracy (about 50-60%)
  • maxmind的GeoIP具有较低的准确度(大约50-60%)
  • ip2country.net has an IP-2-City Database but not free and does not resolve city names for Iran.
  • ip2country.net有一个ip -2城市的数据库,但不是免费的,也不能解析伊朗的城市名。
  • I also tried the DB#.Lite from ipinfodb.com which has an API here without any success. The problem is that, it does not detect many city names.
  • 我也尝试了DB#。ipinfodb.com的Lite在这里有一个API,但是没有成功。问题是,它没有检测到很多城市的名字。
  • I also tried hostip.info API, but it seems to be too slow.
  • 我也尝试了hostip.info API,但是它看起来太慢了。
  • There is a free php class with local DB which resolves only the country name.
  • 有一个带有本地DB的免费php类,它只解析国家名。
  • I dont know if there is chance, using Piwik with this GeoIP plugin. It would be appreciated to have ideas if someone knows about it.
  • 我不知道在这个GeoIP插件中使用Piwik是否有机会。如果有人知道这些想法,我们会很感激。
  • ipinfo.io is another service which does not resolve city names with accuracy.
  • ipinfo。io是另一个不能准确解析城市名称的服务。
  • I dont know if there is a way to use Google analytics to resolve city names, as I think google would be better than any other service regarding countries like Iran.
  • 我不知道是否有办法使用谷歌分析来解析城市名称,因为我认为谷歌在伊朗这样的国家会比其他服务更好。

Any good idea would be really appreciated.

任何好主意都会受到感激。

3 个解决方案

#1


4  

This is a tough one and hard to do reliably. I have given it a go in the past and it went something like this

这是一项艰巨的任务,很难可靠地完成。我过去曾尝试过,结果是这样的

  • Obtain a database of IP addresses, plus cities and countries (http://lite.ip2location.com/database-ip-country-region-city OR http://ipinfodb.com/ip_database.php)
  • 获取IP地址以及城市和国家的数据库(http://lite.ip2location.com/database-ip-country-region-city或http://ipinfodb.com/ip_database.php)
  • Get the IP address and query for it against those tables to find the city and country
  • 获取IP地址并查询这些表以查找城市和国家。
  • Finally check if its in Iran using the country column
  • 最后看看它是否在伊朗使用国别栏

There are paid for services that can do this really quickly for you. It might take you ages to get something working that is still unreliable because you simply do not have the data. I would seriously consider http://www.maxmind.com/en/city_per - unless of course this is a completely none commercial project and $ is a no no.

有一些服务是付费的,可以很快地为你做到这一点。你可能需要很长一段时间才能找到一些仍然不可靠的东西,因为你根本没有数据。我将认真考虑http://www.maxmind.com/en/city_per -除非这当然是一个完全没有商业价值的项目,而且$也不是。

If you can get the lat and long from an IP table, even without the city data then you may want to then use something like this to check for the nearest city of Javascript is an optio n - Finding nearest listed (array?) city from known location.

如果您可以从一个IP表获得lat和long,即使没有城市数据,那么您可能想要使用类似的东西来检查最近的Javascript城市是optio n -从已知位置找到最近的列表(数组?)城市。

What about the browsers Share Location feature?

那么浏览器共享位置特性呢?

#2


0  

If a browser-based solution works for your use case, you might want to look at MaxMind's GeoIP2 JavaScript API. It first attempts to locate the user using HTML5 geolocation and if that fails or is inaccurate, it reverts to MaxMind's GeoIP2 City data (not GeoLite). MaxMind provides a free attribution version.

如果基于浏览器的解决方案适用于您的用例,您可能需要查看MaxMind的GeoIP2 JavaScript API。它首先尝试使用HTML5 geolocation定位用户,如果失败或不准确,它将返回MaxMind的GeoIP2 City数据(不是GeoLite)。MaxMind提供了一个免费的归因版本。

#3


0  

Sometimes we need to use local Geo-IP database instead of web services for particular purposes. This is my experience: I downloaded database form https://db-ip.com. I was searching a lot and finally I found this one more reliable. but still two more problem:

有时,我们需要使用本地地理ip数据库而不是web服务来实现特定的目的。这是我的经验:我下载了数据库表单https://db-ip.com。我找了很多,最后我发现这个更可靠。但还有两个问题:

  • 1-The "IP address to city" database is too huge to upload on MYSQL database on hosting as it pass time out limit.
  • 1-“城市的IP地址”数据库太大,无法在MYSQL数据库上上传,因为它会超时。
  • 2-The Database is base on IP address compare of http://lite.ip2location.com Database is base of IP Numbers.
  • 2-数据库基于http://lite.ip2location.com的IP地址比较,数据库基于IP号。

So I developed a simple .NET app to solve those problems. The solution can be downloaded from here: https://github.com/atoosi/IP2Location-Database-Luncher

所以我开发了一个简单的。net应用程序来解决这些问题。解决方案可以从这里下载:https://github.com/atoosi/ip2locationdatabase - luncher

#1


4  

This is a tough one and hard to do reliably. I have given it a go in the past and it went something like this

这是一项艰巨的任务,很难可靠地完成。我过去曾尝试过,结果是这样的

  • Obtain a database of IP addresses, plus cities and countries (http://lite.ip2location.com/database-ip-country-region-city OR http://ipinfodb.com/ip_database.php)
  • 获取IP地址以及城市和国家的数据库(http://lite.ip2location.com/database-ip-country-region-city或http://ipinfodb.com/ip_database.php)
  • Get the IP address and query for it against those tables to find the city and country
  • 获取IP地址并查询这些表以查找城市和国家。
  • Finally check if its in Iran using the country column
  • 最后看看它是否在伊朗使用国别栏

There are paid for services that can do this really quickly for you. It might take you ages to get something working that is still unreliable because you simply do not have the data. I would seriously consider http://www.maxmind.com/en/city_per - unless of course this is a completely none commercial project and $ is a no no.

有一些服务是付费的,可以很快地为你做到这一点。你可能需要很长一段时间才能找到一些仍然不可靠的东西,因为你根本没有数据。我将认真考虑http://www.maxmind.com/en/city_per -除非这当然是一个完全没有商业价值的项目,而且$也不是。

If you can get the lat and long from an IP table, even without the city data then you may want to then use something like this to check for the nearest city of Javascript is an optio n - Finding nearest listed (array?) city from known location.

如果您可以从一个IP表获得lat和long,即使没有城市数据,那么您可能想要使用类似的东西来检查最近的Javascript城市是optio n -从已知位置找到最近的列表(数组?)城市。

What about the browsers Share Location feature?

那么浏览器共享位置特性呢?

#2


0  

If a browser-based solution works for your use case, you might want to look at MaxMind's GeoIP2 JavaScript API. It first attempts to locate the user using HTML5 geolocation and if that fails or is inaccurate, it reverts to MaxMind's GeoIP2 City data (not GeoLite). MaxMind provides a free attribution version.

如果基于浏览器的解决方案适用于您的用例,您可能需要查看MaxMind的GeoIP2 JavaScript API。它首先尝试使用HTML5 geolocation定位用户,如果失败或不准确,它将返回MaxMind的GeoIP2 City数据(不是GeoLite)。MaxMind提供了一个免费的归因版本。

#3


0  

Sometimes we need to use local Geo-IP database instead of web services for particular purposes. This is my experience: I downloaded database form https://db-ip.com. I was searching a lot and finally I found this one more reliable. but still two more problem:

有时,我们需要使用本地地理ip数据库而不是web服务来实现特定的目的。这是我的经验:我下载了数据库表单https://db-ip.com。我找了很多,最后我发现这个更可靠。但还有两个问题:

  • 1-The "IP address to city" database is too huge to upload on MYSQL database on hosting as it pass time out limit.
  • 1-“城市的IP地址”数据库太大,无法在MYSQL数据库上上传,因为它会超时。
  • 2-The Database is base on IP address compare of http://lite.ip2location.com Database is base of IP Numbers.
  • 2-数据库基于http://lite.ip2location.com的IP地址比较,数据库基于IP号。

So I developed a simple .NET app to solve those problems. The solution can be downloaded from here: https://github.com/atoosi/IP2Location-Database-Luncher

所以我开发了一个简单的。net应用程序来解决这些问题。解决方案可以从这里下载:https://github.com/atoosi/ip2locationdatabase - luncher