当前位置:网站首页>腾讯根据ip解析地址
腾讯根据ip解析地址
2022-04-23 14:00:00 【白云碎里一蓑舟】
//需向腾讯申请key
private static String TXURL = "https://apis.map.qq.com/ws/location/v1/ip?key=&ip=";
public static String getTXCityCodeByIp(String ip) {
CloseableHttpClient httpClient = HttpClients.createDefault();
try {
String requestURL = String.format("%s%s", TXURL, ip);
HttpGet getMethod = new HttpGet(requestURL);
HttpResponse response = httpClient.execute(getMethod);
if (null != response && response.getStatusLine().getStatusCode() == 200) {
return EntityUtils.toString(response.getEntity(), "UTF-8");
}
} catch (Exception e) {
log.error("getTXCityCodeByIp ip:[{}] is Exception:{}", ip, e.toString());
} finally {
try {
httpClient.close();
} catch (IOException e) {
log.error(e.toString());
}
}
return null;
}
public static void main(String[] args) {
String ip = "";
System.out.println(getTXCityCodeByIp(ip));
}
版权声明
本文为[白云碎里一蓑舟]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_49513507/article/details/124324558
边栏推荐
- cnpm的诡异bug
- redis如何解决缓存雪崩、缓存击穿和缓存穿透问题
- 服务器中挖矿病毒了,屮
- [code analysis (6)] communication efficient learning of deep networks from decentralized data
- 解决方案架构师的小锦囊 - 架构图的 5 种类型
- Analysis and understanding of atomicintegerarray source code
- Decentralized Collaborative Learning Framework for Next POI Recommendation
- 33 million IOPs, 39 microsecond delay, carbon footprint certification, who is serious?
- SQL learning | complex query
- 剑南春把文字游戏玩明白了
猜你喜欢
Detailed explanation of redis (Basic + data type + transaction + persistence + publish and subscribe + master-slave replication + sentinel + cache penetration, breakdown and avalanche)
【项目】小帽外卖(八)
Express ② (routing)
Wechat applet
Leetcode brush question 𞓜 13 Roman numeral to integer
About note 1
redis如何解决缓存雪崩、缓存击穿和缓存穿透问题
Express②(路由)
Business case | how to promote the activity of sports and health app users? It is enough to do these points well
cnpm的诡异bug
随机推荐
Leetcode | 38 appearance array
Reading notes: fedgnn: Federated graph neural network for privacy preserving recommendation
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
Expression「Func「TSource, object」」 转Expression「Func「TSource, object」」[]
STM32学习记录0007——新建工程(基于寄存器版)
Program compilation and debugging learning record
The latest development of fed digital currency
【vmware】vmware tools 地址
Choreographer全解析
Neuron and neural network
Es introduction learning notes
Jiannanchun understood the word game
零拷貝技術
Dynamic subset division problem
Un modèle universel pour la construction d'un modèle d'apprentissage scikit
联想产品经理林林:天津当地网络运营商网络故障 ZUI系统后台服务器暂时无法正常工作
Tensorflow Download
[code analysis (3)] communication efficient learning of deep networks from decentralized data
About me
程序编译调试学习记录