package ipconfig;

 import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection; public class gainInformation {
public static void main(String args[]) {
String publicip = getip.publicip();
int ipindex1 = publicip.indexOf("[");
int ipindex2 = publicip.indexOf("]");
String ip = publicip.substring(ipindex1+1, ipindex2);
System.out.println(ip);
int address1 = publicip.indexOf("来自:");
int address2 = publicip.indexOf("</center>");
String substring = publicip.substring(address1+3,address2);
String[] split = substring.split(" ");
for (int i = 0; i < split.length; i++) {
System.out.println(split[i]);
}
}
}
class getip{
public static String publicip() {
BufferedReader br = null;
try {
URL url = new URL("http://20019.ip138.com/ic.asp");
URLConnection urlconn = url.openConnection();
br = new BufferedReader(new InputStreamReader(urlconn.getInputStream()));
String buf,get = null;
while ((buf = br.readLine()) != null) {
get+=buf;
}
return get;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
}

java获取公网ip以及物理地址和代理商的更多相关文章

  1. JAVA获取公网ip

    在ipv4地址稀缺的今天,分配到公网ip几乎是不可能的,但是我拨号之后的ip竟然是公网IP. 将自己的电脑作为服务器·,做点好玩的程序,就成为了可能. 由于运营商的ip是动态分配的公网ip的所以就需要 ...

  2. C#联机获取公网IP

    C#获取IP的方式有很多种,这里通过http://www.ipip.net/这个稳定的在线IP库的来获取公网IP. string tempip = "0.0.0.0"; WebRe ...

  3. python获取公网ip,本地ip及所在国家城市等相关信息收藏

    python获取公网ip的几种方式       from urllib2 import urlopen   my_ip = urlopen('http://ip.42.pl/raw').read() ...

  4. Python 之自动获取公网IP

    Python 之自动获取公网IP 2017年9月30日 文档下载:https://wenku.baidu.com/view/ff40aef7f021dd36a32d7375a417866fb84ac0 ...

  5. Delphi获取公网IP地址函数

    uses IdHTTP; function GetPublicIP: string; var strIP, URL: string; iStart, iEnd: Integer; MyIdHTTP: ...

  6. 获取本地ip和获取公网ip

    import socket def get_local_ip(): ''' 获取本地ip地址 :return: ''' s = socket.socket(socket.AF_INET, socket ...

  7. python获取公网ip的几种方式

    python获取公网ip的几种方式 转 https://blog.csdn.net/conquerwave/article/details/77666226 from urllib2 import u ...

  8. Java获取用户ip

    /** * 获取客户端ip地址(可以穿透代理) * * @param request * @return */ public static String getRemoteAddr(HttpServl ...

  9. java获取服务器IP地址及MAC地址的方法

    这篇文章主要介绍了java编程实现获取机器IP地址及MAC地址的方法,实例分析了Java分别针对单网卡及多网卡的情况下获取服务器IP地址与MAC地址的相关技巧,需要的朋友可以参考下   本文实例讲述了 ...

随机推荐

  1. MVC架构在游戏开发中的应用

    一 定义 MVC即Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写. MVC是一种"前端"的设计模式. MV ...

  2. 2016/04/29 smarty模板 1, 初步 目标 : 变量 运算符 表达式 流程控制 函数

    ① 从配置文件中读取配置: 1,在模板页面加载配置文件 html页面 不是php页面 <{config_load file='fo.conf'}> 2,在需要用到配置的地方加 <{# ...

  3. H5的localStorage简单存储删除

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  4. linux系统编程之进程(七):system()函数使用【转】

    本文转载自:http://www.cnblogs.com/mickole/p/3187974.html 一,system()理解 功能:system()函数调用“/bin/sh -c command” ...

  5. validationEngine验证的使用

    改校验的方法功能很强大,具体查看api http://code.ciaoca.com/jquery/validation_engine/ 效果:

  6. codeforces 688E E. The Values You Can Make(dp)

    题目链接: E. The Values You Can Make time limit per test 2 seconds memory limit per test 256 megabytes i ...

  7. 并不对劲的bzoj4012:loj2116:p3241: [HNOI2015]开店

    题目大意 有一棵\(n\)(\(n\leq1.5*10^5\))个节点的二叉树,有点权\(x\),边权\(w\),\(q\)(\(q\leq2*10^5\))组询问,每组询问给出\(u,l,r\),求 ...

  8. BZOJ_2821_作诗(Poetize)_分块

    BZOJ_2821_作诗(Poetize)_分块 Description 神犇SJY虐完HEOI之后给傻×LYD出了一题:SHY是T国的公主,平时的一大爱好是作诗.由于时间紧迫,SHY作完诗 之后还要 ...

  9. 稳定婚姻(tarjan)

    传送门 这道题一开始可能以为是二分图匹配……?不过后来发现和二分图没啥大关系. 简单分析之后发现,把夫妻之间连边(男性向女性连边),之后再将每对曾经是情侣的人连边(女性向男性连边),当然以上的方向可以 ...

  10. UVa 1213 Sum of Different Primes (DP)

    题意:给定两个数 n 和 k,问你用 k 个不同的质数组成 n,有多少方法. 析:dp[i][j] 表示 n 由 j 个不同的质数组成,然后先打表素数,然后就easy了. 代码如下: #pragma ...