Java_调用HttpRequest访问淘宝开发API查询IP信息
来源:互联网 发布:汇川 4da编程 编辑:程序博客网 时间:2024/05/21 06:26
/** * 获取ip信息 * * @param ip * @return */ public static String getIpInfo(String ip) { String httpUrl = "http://ip.taobao.com/service/getIpInfo.php"; String httpArg = "ip=" + ip; String jsonResult = httpRequest(httpUrl, httpArg); String ipInfo = "请搜索IP查询"; if (jsonResult != null) { /* * {"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"}} * */ try { JSONObject jsonObject = JSONObject.fromObject(jsonResult); if (jsonObject.get("code").toString().equals("0")) { JSONObject data = jsonObject.getJSONObject("data"); // 国家/地区 String country = data.getString("country"); // 区域,如华东 String area = data.getString("area"); // 省份 String region = data.getString("region"); // 城市 String city = data.getString("city"); // 县 String county = data.getString("county"); // 运营商 String isp = data.getString("isp"); ipInfo = region + city + county + isp; } } catch (Exception e) { //解析失败 } } return ipInfo; }
其中调用了httpRequest方法请我的另一篇博文。
阅读全文
1 0
- Java_调用HttpRequest访问淘宝开发API查询IP信息
- php通过淘宝API查询IP地址归属等信息
- PHP调用淘宝IP地址查询接口查询IP所在地信息实例
- 新浪网易IP地区信息查询API接口调用方法
- IP地址地区信息查询API接口调用方法
- IP地址地区信息查询API接口调用方法
- 新浪网易IP地区信息查询API接口调用方法
- 使用Java HttpClient访问淘宝Ip查询接口获取具体位置信息
- JAVA 调用淘宝IP地址库API
- 调用淘宝接口查询IP所在地
- 从淘宝API根据IP获取IP城市信息
- 淘宝API——获取IP归属地等信息
- 淘宝API——获取IP归属地等信息
- go 通过淘宝api,查询出口ip详细信息
- 淘宝网查询IP地址信息的服务地址
- 关于调用淘宝IP获取城市信息-- 随笔
- 根据浏览者的IP切换成不同语言,新浪网易IP地区信息查询API接口调用方法
- 根据浏览者的IP切换成不同语言,新浪网易IP地区信息查询API接口调用方法
- mysql limit分页的坑 数据库分页优化
- Linux上安装JDK
- ubuntu无法挂载window下d盘
- 编译TinyX
- Android基于腾讯云的视频聊天研究
- Java_调用HttpRequest访问淘宝开发API查询IP信息
- redhat配置yum源
- 在java程序中设置http代理访问网络
- easyui的datebox控件如何只要年月
- Android消息推送认知
- mmap 访问DDR,加了 O_RDWR| O_SYNC,仍不能同步
- Unity3D动画帧事件
- substring和substr的区别
- 欢迎使用CSDN-markdown编辑器