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地址的相关技巧,需要的朋友可以参考下 本文实例讲述了 ...
随机推荐
- js和jquery实现回到顶层
js <!DOCTYPE html> <html> <head> <title>返回顶部</title> <style> bod ...
- 比 git log 更强大的 git reflog
最近做了个骚操作 git checkout commitId 修改了部分内容 git add . git commit -m '修改了些东西' -> 此时git 会自动生成一个新的 comm ...
- web 界面设计---大道至简
http://www.cnblogs.com/coder2012/p/4023442.html 一个非常精简的webpy页面博客 qing.weibo.com 新浪的轻微博也不错精简
- 访问某类型的元数据的方式-TypeDescriptor 类
.NET Framework 提供了两种访问某类型的元数据的方式:通过 System.Reflection 命名空间中提供的反射 API,以及通过 TypeDescriptor 类.反射是可用于所有类 ...
- 第一个get请求的爬虫程序
一:urllib库: urllib是Python自带的一个用于爬虫的库,器主要作用就是可以通过代码模拟浏览器发送请求.其被用到子模块在Python3中的urllib.request和urllib.pa ...
- 跨域,Content-Type组件
1,跨域:是浏览器的同源策略 阻止ajax请求不组织src请求 2,一个源的定义:如果两个页面的协议,端口(如果由指定)和域名都相同,则两个页面具有相同的源 下面给出相对http://a.xyz.co ...
- ZOJ 3962 E.Seven Segment Display / The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple E.数位dp
Seven Segment Display Time Limit: 1 Second Memory Limit: 65536 KB A seven segment display, or s ...
- mysql -=- DDL
net start mysql mysql -uroot -p show databases use 数据库名 how tables --------------------------------- ...
- 字符串输出输入函数,const修饰符,内存分区,动态内存管理,指针和函数,结构体
1.字符串输出输入函数 读入字符串的方法: 1) scanf 特点:不能接收空格 2) gets 特点:可以接受含有空格的字符串 ,不安全 3) fgets(); 特点:可以帮我们自动根据数组的长度截 ...
- 使用maven新建类目录是,报错The folder is already a source folder.的解决办法
转自:https://www.cnblogs.com/loger1995/p/6539139.html 我们有时候新建一个webapp的maven项目时,生成的目录结构是这样子的: 缺少maven规范 ...