ip地址定位2

来源:互联网 发布:苹果笔记本mac有光驱吗 编辑:程序博客网 时间:2024/04/30 02:49

这里写图片描述

1、淘宝

JSONObject obj2 = obj.getJSONObject("data");                String code = obj.getString("code");                if (code.equals("0")) {                    result = obj2.getString("region") + ","+obj2.getString("city");                } else {                }

2、新浪

String[] temp = returnStr.split(",");                    String provice = temp[4];                    if(provice!=null){                        String[] province2 = provice.split(":");                        provice = province2[1];                        provice = provice.substring(provice.indexOf("\"")+1, provice.lastIndexOf("\""));                    }                    String city = temp[5];                    if(city!=null){                        String[] city2 = city.split(":");                        city = city2[1];                        city = city.substring(city.indexOf("\"")+1, city.lastIndexOf("\""));                    }                    result = decodeUnicode(provice)+"省,"+decodeUnicode(city)+"市";

3、腾讯

JSONObject jsonobject = JSONObject.fromObject(result);                        TxApi api = (TxApi)JSONObject.toBean(jsonobject,TxApi.class);                    result = api.getResult().getAd_info().getProvince()+","+api.getResult().getAd_info().getCity();

4、高德

JSONObject obj = JSONObject.fromObject(returnStr);                    result = obj.getString("province")+","+obj.getString("city");

5、搜狐

String returnStrs[] = returnStr.split(",");                returnStr = returnStrs[2];                String returnStrs2[] = returnStr.split("\"");                result = returnStrs2[3];

5、百度

JSONObject obj = JSONObject.fromObject(returnStr);                    BaiduMap api = (BaiduMap)JSONObject.toBean(obj,BaiduMap.class);                    result = api.getContent().getAddress_detail().getProvince()+","+                            api.getContent().getAddress_detail().getCity();

下载地址:链接:http://pan.baidu.com/s/1i5wVRnf 密码:br99

全CSDN的丰(好)色(se)博客,这里有书本看不到的Java技术,电影院禁播的电影,欢迎关注QQ群494808400

0 0