@@ -0,0 +1,1427 @@
+package com.xqbase.util.sns;%0D%0A%0D%0Aimport java.io.IOException;%0D%0Aimport java.nio.charset.StandardCharsets;%0D%0A%0D%0Aimport com.xqbase.util.ByteArrayQueue;%0D%0Aimport com.xqbase.util.http.HttpPool;%0D%0A%0D%0Apublic class Ip138Ip %7B%0D%0A%09public static class Exception extends java.lang.Exception %7B%0D%0A%09%09private static final long serialVersionUID = 1L;%0D%0A%0D%0A%09%09public Exception(String message) %7B%0D%0A%09%09%09super(message);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09private static final String SERVICE_URL =%0D%0A%09%09%09%22http://m.ip138.com/ip.asp?ip=%22;%0D%0A%0D%0A%09private static HttpPool httpPool = new HttpPool(SERVICE_URL, 15000);%0D%0A%0D%0A%09public static HttpPool getHttpPool() %7B%0D%0A%09%09return httpPool;%0D%0A%09%7D%0D%0A%0D%0A%09public static String getIpInfo(String ip) throws Exception %7B%0D%0A%09%09ByteArrayQueue response = new ByteArrayQueue();%0D%0A%09%09try %7B%0D%0A%09%09%09int status = httpPool.get(ip, null, response, null);%0D%0A%09%09%09if (status != 200) %7B%0D%0A%09%09%09%09throw new Exception(%22Error Getting %22 + ip +%0D%0A%09%09%09%09%09%09%22: %22 + status + %22, %22 + response);%0D%0A%09%09%09%7D%0D%0A%09%09%09String html = response.toString(StandardCharsets.UTF_8);%0D%0A%09%09%09int i = html.indexOf(%22%3Cp class=%5C%22result%5C%22%3E%E6%9C%AC%E7%AB%99%E4%B8%BB%E6%95%B0%E6%8D%AE%EF%BC%9A%22);%0D%0A%09%09%09if (i %3C 0) %7B%0D%0A%09%09%09%09throw new Exception(%22Error Getting %22 + ip + %22: %22 + html);%0D%0A%09%09%09%7D%0D%0A%09%09%09i += 24;%0D%0A%09%09%09int j = html.indexOf(%22%3C/p%3E%22, i);%0D%0A%09%09%09if (j %3C 0) %7B%0D%0A%09%09%09%09throw new Exception(%22Error Getting %22 + ip + %22: %22 + html);%0D%0A%09%09%09%7D%0D%0A%09%09%09return html.substring(i, j);%0D%0A%09%09%7D catch (IOException e) %7B%0D%0A%09%09%09throw new Exception(%22Error Getting %22 + ip +%0D%0A%09%09%09%09%09%22: %22 + e.getMessage() + %22, %22 + response);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D

add ip138