当前位置:网站首页>腾讯根据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
边栏推荐
- Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
- Program compilation and debugging learning record
- JS force deduction brush question 102 Sequence traversal of binary tree
- [code analysis (3)] communication efficient learning of deep networks from decentralized data
- SSM project deployed in Alibaba cloud
- Business case | how to promote the activity of sports and health app users? It is enough to do these points well
- 淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
- What is the difference between blue-green publishing, rolling publishing and gray publishing?
- Android 面试主题集合整理
- 项目中遇到的问题(五)操作Excel接口Poi的理解
猜你喜欢
Leetcode brush question 𞓜 13 Roman numeral to integer
Detailed explanation of redis (Basic + data type + transaction + persistence + publish and subscribe + master-slave replication + sentinel + cache penetration, breakdown and avalanche)
Dynamic subset division problem
Reading notes: meta matrix factorization for federated rating predictions
go 语言 数组,字符串,切片
MySQL [read / write lock + table lock + row lock + mvcc]
SSM project deployed in Alibaba cloud
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
Express中间件③(自定义中间件)
随机推荐
OSS cloud storage management practice (polite experience)
服务器中挖矿病毒了,屮
Expression「Func「TSource, object」」 转Expression「Func「TSource, object」」[]
淘宝发布宝贝提示“您的消保保证金额度不足,已启动到期保障”
SQL learning | set operation
Problems encountered in the project (V) understanding of operating excel interface poi
VsCode-Go
JS force deduction brush question 103 Zigzag sequence traversal of binary tree
Pytorch 经典卷积神经网络 LeNet
Express②(路由)
Chapter 15 new technologies of software engineering
1256:献给阿尔吉侬的花束
[code analysis (1)] communication efficient learning of deep networks from decentralized data
MySQL [SQL performance analysis + SQL tuning]
初识go语言
[code analysis (2)] communication efficient learning of deep networks from decentralized data
AtCoder Beginner Contest 248C Dice Sum (生成函数)
Express ② (routage)
scikit-learn构建模型的万能模板
MySQL 修改主数据库