当前位置:网站首页>腾讯根据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
边栏推荐
- Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
- 初探 Lambda Powertools TypeScript
- 自动化的艺术
- SQL: How to parse Microsoft Transact-SQL Statements in C# and to match the column aliases of a view
- [code analysis (3)] communication efficient learning of deep networks from decentralized data
- redis如何解决缓存雪崩、缓存击穿和缓存穿透问题
- Pytorch 经典卷积神经网络 LeNet
- SQL learning | set operation
- Modify the Jupiter notebook style
- Choreographer全解析
猜你喜欢

Small case of web login (including verification code login)

趣谈网络协议

Record a strange bug: component copy after cache component jump
![MySQL [SQL performance analysis + SQL tuning]](/img/71/2ca1a5799a2c7a822158d8b73bd539.png)
MySQL [SQL performance analysis + SQL tuning]

Oracle告警日志alert.log和跟踪trace文件中文乱码显示

UML Unified Modeling Language
![MySQL [read / write lock + table lock + row lock + mvcc]](/img/a9/ace85899a01a7d4fd80b2e631e44d6.png)
MySQL [read / write lock + table lock + row lock + mvcc]

Express middleware ③ (custom Middleware)

Modify the Jupiter notebook style

JUC interview questions about synchronized, ThreadLocal, thread pool and atomic atomic classes
随机推荐
Dynamic subset division problem
[code analysis (3)] communication efficient learning of deep networks from decentralized data
MySQL 修改主数据库
Pytorch 经典卷积神经网络 LeNet
基于Ocelot的gRpc网关
Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
MySQL [read / write lock + table lock + row lock + mvcc]
Express中间件③(自定义中间件)
SQL learning | complex query
分页SQL
初探 Lambda Powertools TypeScript
Express②(路由)
Program compilation and debugging learning record
Oracle告警日志alert.log和跟踪trace文件中文乱码显示
[code analysis (6)] communication efficient learning of deep networks from decentralized data
Choreographer full resolution
Android 面试主题集合整理
零拷貝技術
Elmo (bilstm-crf + Elmo) (conll-2003 named entity recognition NER)
STM32 learning record 0007 - new project (based on register version)