java获取公网ip以及物理地址和代理商
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以及物理地址和代理商的更多相关文章
- JAVA获取公网ip
在ipv4地址稀缺的今天,分配到公网ip几乎是不可能的,但是我拨号之后的ip竟然是公网IP. 将自己的电脑作为服务器·,做点好玩的程序,就成为了可能. 由于运营商的ip是动态分配的公网ip的所以就需要 ...
- C#联机获取公网IP
C#获取IP的方式有很多种,这里通过http://www.ipip.net/这个稳定的在线IP库的来获取公网IP. string tempip = "0.0.0.0"; WebRe ...
- python获取公网ip,本地ip及所在国家城市等相关信息收藏
python获取公网ip的几种方式 from urllib2 import urlopen my_ip = urlopen('http://ip.42.pl/raw').read() ...
- Python 之自动获取公网IP
Python 之自动获取公网IP 2017年9月30日 文档下载:https://wenku.baidu.com/view/ff40aef7f021dd36a32d7375a417866fb84ac0 ...
- Delphi获取公网IP地址函数
uses IdHTTP; function GetPublicIP: string; var strIP, URL: string; iStart, iEnd: Integer; MyIdHTTP: ...
- 获取本地ip和获取公网ip
import socket def get_local_ip(): ''' 获取本地ip地址 :return: ''' s = socket.socket(socket.AF_INET, socket ...
- python获取公网ip的几种方式
python获取公网ip的几种方式 转 https://blog.csdn.net/conquerwave/article/details/77666226 from urllib2 import u ...
- Java获取用户ip
/** * 获取客户端ip地址(可以穿透代理) * * @param request * @return */ public static String getRemoteAddr(HttpServl ...
- java获取服务器IP地址及MAC地址的方法
这篇文章主要介绍了java编程实现获取机器IP地址及MAC地址的方法,实例分析了Java分别针对单网卡及多网卡的情况下获取服务器IP地址与MAC地址的相关技巧,需要的朋友可以参考下 本文实例讲述了 ...
随机推荐
- HDOJ 4455 Substrings 递推+树状数组
pre[i]第i位数往前走多少位碰到和它同样的数 dp[i]表示长度为i的子串,dp[i]能够由dp[i-1]加上从i到n的pre[i]>i-1的数减去最后一段长度为i-1的断中的不同的数得到. ...
- 6 JobApp默认视图开发
第一步:引入angularjs 添加app模块 现在我们正式进入开发,下面是我们在上一节建立的目录结构: 我们需要再src路径下,新建index.html文件,先引入angularjs文件: < ...
- the first week study
1.In 1989, a man named Guido create "python" as a kind of computer languages. And now we u ...
- Eclipse添加Qt插件
此文件仅为步骤操作作一个记录,以便以后方便查阅. 1.操作大体参考这个网站:http://blog.csdn.net/defonds/article/details/5013412 2.我的运行环境: ...
- Oracle - 数据更新 - 增删改
/* 数据的更新 增加 删除 修改 */ -----------------------------------增加(一次只能插入一条数据) --自定义插入数据列的顺序 ,,); --按照数据库默认的 ...
- java集合的关系
在 Java2中,有一套设计优良的接口和类组成了Java集合框架Collection,使程序员操作成批的数据或对象元素极为方便.这些接口和类有很多对抽象数据类型操作的API,而这是我们常用的且在数据结 ...
- gearcache在qemu-kvm虚拟化平台下的实现
需要用到的数据结构: 链表,基树. gearcache在qemu-kvm虚拟化平台下的实现主要有以下的步骤: 1.打开镜像文件的时候,为gearcache中的基数池(page_node_pool)和读 ...
- [SCOI 2007] 修车
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1070 [算法] 首先 , 我们发现 , 在倒数第i个修车会对答案产生i * k的贡献 ...
- 使用Visual Studio 利用WinGDB编译和远程调试嵌入式Linux的程序
写这篇文章的目的在于帮助那些既要使用Visual Studio编写程序又要开发和调试嵌入式Linux 程序的苦命程序员们! 第一步, 安装 WinGDB ,下载位置 http://www.wingd ...
- bzoj1858 [Scoi2010]序列操作——线段树
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1858 线段树...调了一个上午...(后面带 // 的都是改出来的) lazy 标记的下放好 ...