我已经导入了maxmind Dll并下载了GeoIp.dat数据库,以获取我已使用以下代码的IP地址的国家名称
Dim ls As New LookupService("GeoIP.dat", LookupService.GEOIP_MEMORY_CACHE)
'get country of the ip address
Dim c As Country = ls.getCountry("24.24.24.24")
Console.Write(" code: " & c.getCode() & vbLf)
Console.Write(" name: " & c.getName() & vbLf)
CountryName.Text = " name: " & c.getName() & vbLf
但是
Dim c As Country = ls.getCountry("24.24.24.24")
给我以下错误数据库已关闭。可能是什么问题
Dim ls As New LookupService(MapPath ("GeoIP.dat"), LookupService.GEOIP_MEMORY_CACHE)
Dim c As Country = ls.getCountry("24.24.24.24")
Console.Write(" code: " & c.getCode() & vbLf)
Console.Write(" name: " & c.getName() & vbLf)
CountryName.Text = " name: " & c.getName() & vbLf
1)首先需要根据您的平台(如应用程序或Web或相应语言)使用您可以使用的IP地址。
2)然后在后端中,使用任何给定的链接发出卷曲请求,并获得带有国家,州,城市,坐标等的完整位置数组。
http://www.geoplugin.net/php.gp?ip=123.123.123.123
http://ip-api.com/php/123.123.123.123
http://ipinfo.io/123.123.123.123
http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=12
有关完整的教程,请访问here