是否有任何方法利用maxmind通过用户的IP获取城市代码?
在下面的示例中,我可以获得城市的名称,但不能获得cityCodes。据我所知,maxmind不支持城市法规;
关于maxmind支持的参考文件:https://www.maxmind.com/en/geoip2-city
;等
private static DatabaseReader reader = null;
InetAddress inetAddress = InetAddress.getByName(ipAddress);
CityResponse response = reader.city(inetAddress);
String cityName = response.getCity().getName(); //Istanbul
String cityCode = response.getCity().???code???; // The desired output : IST发布于 2015-08-18 13:46:18
据我所知,联合国/LOCODE是您所要求的最接近的匹配。MaxMind本身并不在其数据集中提供这些代码,但它确实为城市提供了一个geoname_id,可用于在GeoNames数据集中查找城市。GeoNames在其保费数据集中提供UN/LOCODE。
https://stackoverflow.com/questions/32045447
复制相似问题