private static String getInternetIp() throws Exception{
try {
// 打開連接
Document doc = Jsoup.connect("http://chaipip.com/").get();
Elements eles = doc.select("#ip");
return eles.attr("value");
}catch (IOException e) {
e.printStackTrace();
}
return InetAddress.getLocalHost().getHostAddress();
}
公網ip轉城市用ip2Region,附上鍊接: