-
根据IP获取地理位置
2017-05-16 10:52:51依赖第三方接口,根据IP获取地理位置,Java实现代码如下: import com.google.gson.Gson; import com.google.gson.internal.LinkedTreeMap; import java.io.BufferedReader; import java.io.IOException; ...依赖第三方接口,根据IP获取地理位置,Java实现代码如下:
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;//根据IP获取国家省份城市
public class IPAnalyse {
public static void main(String[] args) throws IOException {
String ip = "61.157.45.92";
String add[] = getAddressByIP1(ip);
System.out.println("国家:"+ add[0] +",省份:"+ add[1] +",城市:"+add[2]);
}
public static String[] getAddressByIP1(String strIP) throws IOException {
URL url = new URL("http://ip.taobao.com/service/getIpInfo.php?ip=" + strIP);
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line = null;
StringBuilder result = new StringBuilder();
while ((line = reader.readLine()) != null) {
result.append(line);
}
reader.close();
String res = result.toString();
Gson gson = new Gson();
HashMap<String, Object> kv = gson.fromJson(res, HashMap.class);
LinkedTreeMap map = (LinkedTreeMap) kv.get("data");
String[] location = new String[3];
location[0] = ""; //国家
location[1] = ""; //省份
location[2] = ""; //市区
if ((map != null) && (!map.isEmpty())) {
location[0] = (String) map.get("country");
location[1] = (String) map.get("region");
location[2] = (String) map.get("city");
}
return location;
}
} -
根据ip获取地理位置
2017-11-23 18:20:00使用到的是淘宝提供的API 1. 请求接口(GET): http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串] 2. 响应信息: (json格式的)国家 、省(自治区或直辖市...{"code":0,"data":{"ip":"210.75.225.2...使用到的是淘宝提供的API
1. 请求接口(GET):
http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串]
2. 响应信息:
(json格式的)国家 、省(自治区或直辖市)、市(县)、运营商
3. 返回数据格式:
{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}本文转自 hgditren 51CTO博客,原文链接:http://blog.51cto.com/phpme/1580012,如需转载请自行联系原作者 -
Node.js和PHP根据ip获取地理位置的方法
2020-10-26 03:53:26主要介绍了Node.js和PHP根据ip获取地理位置的方法,通过新浪接口根据IP地址获取所在城市,需要的朋友可以参考下 -
java 根据ip获取地理位置
2011-06-15 18:33:36java 根据ip获取地理位置,包括数据文件。。。。。。。 -
PHP安装GeoIP扩展根据IP获取地理位置及计算距离的方法
2020-10-22 00:15:29主要介绍了PHP安装GeoIP扩展根据IP获取地理位置及计算距离的方法,包括获取目标IP所在的国家地区等信息,需要的朋友可以参考下 -
根据IP获取地理位置——Java实现
2017-10-13 15:55:28依赖第三方接口,根据IP获取地理位置,Java实现代码如下:依赖第三方接口,根据IP获取地理位置,Java实现代码如下:
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;//根据IP获取国家省份城市
public class IPAnalyse {public static void main(String[] args) throws IOException { String ip = "61.157.45.92"; String add[] = getAddressByIP1(ip); System.out.println("国家:"+ add[0] +",省份:"+ add[1] +",城市:"+add[2]); } public static String[] getAddressByIP1(String strIP) throws IOException { URL url = new URL("http://ip.taobao.com/service/getIpInfo.php?ip=" + strIP); URLConnection conn = url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); String line = null; StringBuilder result = new StringBuilder(); while ((line = reader.readLine()) != null) { result.append(line); } reader.close(); String res = result.toString(); Gson gson = new Gson(); HashMap<String, Object> kv = gson.fromJson(res, HashMap.class); LinkedTreeMap map = (LinkedTreeMap) kv.get("data"); String[] location = new String[3]; location[0] = ""; //国家 location[1] = ""; //省份 location[2] = ""; //市区 if ((map != null) && (!map.isEmpty())) { location[0] = (String) map.get("country"); location[1] = (String) map.get("region"); location[2] = (String) map.get("city"); } return location; }
}
-
纯真IP库实现根据IP获取地理位置
2014-05-05 16:49:46纯真IP库实现根据IP获取地理位置关于“纯真IP库”,文章推荐:http://lumaqq.linuxsir.org/article/qqwry_format_detail.html
纯真IP库实现根据IP获取地理位置
-
python根据ip获取地理位置_使用python根据ip获取目标地理位置信息
2021-01-14 13:00:5087 ip_end = ip_address.split('-')[1]88 #如果ip地址范围一样,则直接执行 89 if(ip_start ==ip_end):90 try:91 seperate_ip(ip_address.split('-')[0])92 exceptException as e:93 printe94 elif ip_start >ip_end... -
新浪根据IP获取地理位置————————大坑
2018-07-25 16:23:24不知从何时开始,新浪根据IP获取地理位置的接口关闭了,导致了网站从响应时间十几毫秒到二十几秒的增加,超级慢。 如果网站使用新浪接口请大家自行查找... -
直接上Java代码根据ip获取地理位置.....
2019-01-12 15:04:07java代码根据ip获取地理位置 获取地理位置的工具类 public class AddressUtils { // 主方法测试 /public static void main(String[] args) { AddressUtils addressUtils = new AddressUtils(); // 测试ip 110.184.68... -
PHP 根据IP获取地理位置
2018-05-15 18:08:001 /** 2 * 根据用户IP获取用户地理位置 3 * $ip 用户ip 4 */ 5 function get_position($ip){ 6 if(empty($ip)){ 7 return '缺少用户ip'; 8 } 9 $url = 'http://ip.taobao.co... -
PHP中使用Node.js根据ip获取地理位置的方法代码
2017-06-24 19:56:30这篇文章主要介绍了PHP中使用Node.js根据ip获取地理位置的方法,通过新浪接口根据IP地址获取所在城市,需要的朋友可以参考下 一、Node.js实现代码 var http = require('http'); var util = require('util'); /** *... -
(分享)根据IP获取地理位置(百度API)
2016-12-26 20:43:00(分享)根据IP获取地理位置(百度API) 说明: 本程序调用的百度地图接口 http://lbsyun.baidu.com/index.php?title=webapi/high-acc-ip#h. 使用C#语言+VS2015 IDE开发 效果图: ... -
c#根据ip获取地理位置
2019-09-29 02:51:25ip = GetIpAddress.GetUserIp(); string jsonstr = HttpGet( " http://api.map.baidu.com/location/ip?ak=rg3c2fj4QBZwa6v3h1w95Sp9&ip= " + ip); JObject jo = (JObject)JsonConvert.DeserializeObject... -
java根据ip获取地理位置
2018-01-29 15:44:57* 根据IP地址获取详细的地域信息 * * @author Lwl * @dateJan 26, 2016 */ public class AddressUtils { /** * * @param content * 请求的参数 格式为:name=xxx&pwd=xxx * @param encoding * ... -
php根据ip获取地理位置
2016-10-18 15:23:17有这样的需求,需要根据用户的IP地址,定位用户所在的城市。 本文记录性文章,无逻辑性。有这样需求的朋友,可以直接拷贝使用。直接上代码,不需赘述。 header('Content-Type:text/html;Charset=utf-8'); ... -
根据ip获取地理位置,淘宝接口
2019-07-24 16:52:00/** * * @param content * 请求的参数 格式为:name=xxx&pwd=xxx * @param encodingString * 服务器端请求编码。... * @throws ... getAddresses("ip="+ip, "UTF-8"); } -
获取ip以及根据ip获取地理位置,经纬度等信息(增加重试机制)
2020-10-17 15:29:42//根据ip获取位置 getLocationService.getLocationByIp(ip); }).catch(response => { //获取ip失败,换下一个url获取 getLocationService.getIp(); }); } else { //获取ip失败 getLocationService.reject(null); } ... -
Android根据IP获取地理位置,精确到经纬度
2013-07-03 09:06:40摘要:每一个联网的设备都有一个IP地址,移动设备也不例外,如何定位Android手机当前的地理位置呢?很简单,我们依然可以利用 IP地址来获取Android手机的当前位置,可以精确到经纬度。 本文就直接以代码的方式演示... -
java根据url获取json对象 java根据ip获取地理位置
2013-07-16 16:38:12* java根据 url获取 json对象 * @author openks * @since 2013-7-16 * 需要添加java-json.jar才能运行 */ public class GetPlaceByIp { private static String readAll(Reader rd) throws IOException { ... -
根据ip获取地理位置java(调用淘宝接口)
2014-12-11 09:42:00URL("http://ip.taobao.com/service/getIpInfo.php?ip="+"27.223.68.94"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.... -
根据ip地址获取地理位置及坐标
2020-08-20 22:05:52根据ip获取地理位置信息,不用http和webservice接口,减少请求时间。我们可以利用了GeoLite2 库,GeoLite2 数据库是一个免费的 IP 地理定位数据库,GeoLite2 Country 与 City 数据库在每月的第一个周二更新。GeoLite...
-
java从零开发贪吃蛇游戏全流程
-
raspi_video_car.zip
-
SOA实战:BPEL和SCA案例研究
-
敏捷软件开发和极限编程介绍
-
基于Qt的LibVLC开发教程
-
数学建模A乘车难问题.zip
-
Java NIO之直接缓冲区和非直接缓冲区
-
Study on digital holography with single phase-shifting operation
-
架构腐化之谜
-
Jsplumb从入门到实战
-
MySQL你该了解的那些事【服务端篇】
-
关于Android的一些设计
-
MySQL Router 实现高可用、负载均衡、读写分离
-
【MyBatis】执行原理(一):创建会话工厂(SqlSessionFactory) 源码分析
-
高中地理湘教版必修一三圈环流.docx
-
【区块链基础】1——密码学
-
生成和解析JSON
-
libFuzzer视频教程
-
Scala基础-源码
-
Android手机开发(二)