当前位置:网站首页>Tencent resolves the address according to the IP address
Tencent resolves the address according to the IP address
2022-04-23 16:49:00 【A coir boat in the broken white clouds】
// Need to apply to Tencent 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));
}
版权声明
本文为[A coir boat in the broken white clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400067875.html
边栏推荐
- feign报400处理
- Installing labellmg tutorial in Windows
- Phpstudy V8, a commonly used software for station construction 1 graphic installation tutorial (Windows version) super detailed
- 【Pygame小游戏】10年前风靡全球的手游《愤怒的小鸟》,是如何霸榜的?经典回归......
- Easyexcel reads the geographical location data in the excel table and sorts them according to Chinese pinyin
- Use case execution of robot framework
- Use itextpdf to intercept the page to page of PDF document and divide it into pieces
- Use if else to judge in sail software - use the title condition to judge
- Calculate pie chart percentage
- Public variables of robotframework
猜你喜欢
1959年高考数学真题
各大框架都在使用的Unsafe类,到底有多神奇?
MySql主从复制
Real time operation of vim editor
[pyGame games] how did angry birds, a mobile game that became popular all over the world 10 years ago, dominate the list? Classic return
批量制造测试数据的思路,附源码
CentOS MySQL multi instance deployment
The new MySQL table has a self increasing ID of 20 bits. The reason is
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
Getting started with JDBC
随机推荐
Camtasia2022软件新增功能介绍
Esxi encapsulated network card driver
05 Lua control structure
05 Lua 控制结构
100 deep learning cases | day 41 - convolutional neural network (CNN): urbansound 8K audio classification (speech recognition)
An essay on the classical "tear down the wall in thinking"
Encapsulating the logging module
Detailed explanation of the penetration of network security in the shooting range
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
Introduction notes to PHP zero Foundation (13): array related functions
【PIMF】OpenHarmony啃论文俱乐部—在ACM Survey闲逛是什么体验
Getting started with JDBC
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
Pytorch: the pit between train mode and eval mode
Introduction to how to set up LAN
LVM与磁盘配额
DDT + Excel for interface test
Nifi fast installation and file synchronization
Introduction to new functions of camtasia2022 software
CentOS MySQL multi instance deployment