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地址的相关技巧,需要的朋友可以参考下 本文实例讲述了 ...
随机推荐
- Django创建数据表
Django中创建表. 用的django项目自带的sqlite数据库,创建完毕后将表注冊到jdango.admin,就能够在浏览器在管理了. 在django项目的models.py文件里: from ...
- Part1-Redefining your data-access strategy 重新定义你的数据访问策略
欢迎来到Entity Framework 4 In Action,EF是微软3.5 SP1推出的ORM工具,现在已经更新到4.0版本(...)本书能确保你in a robust and model- ...
- 高清摄像头MIPI CSI2接口浅解【转】
本文转载自:http://blog.csdn.net/u012075739/article/details/44672435 MIPI摄像头常见于手机.平板中,支持500万像素以上高清分辨率.它的全称 ...
- 疯狂JAVA——数组
java是静态语言,java数组也是静态语言 静态初始化: String[] a = new String[]{ "我"}; String[] b = { "你" ...
- mac idea 内存
vim /Applications/IntelliJ\ IDEA.app/Contents/bin/idea.vmoptions -Xms512m -Xmx2048m -XX:ReservedCode ...
- 《StarGAN: Unified Generative Adversarial Networks for Multi-Domain Image-to-Image Translation》论文笔记
---恢复内容开始--- Motivation 使用单组的生成器G和判别训练图片在多个不同的图片域中进行转换 效果确实很逆天,难怪连Good Fellow都亲手给本文点赞 Introduction 论 ...
- 《Deep Learning Face Attributes in the Wild》论文笔记
论文背景: IEEE International Conference on Computer Vision 2015 Ziwei Liu1, Ping Luo1, Xiaogang Wang2, X ...
- 【188】HTML + CSS + JS 学习网站
RGB 取色器 HTML 参考手册 CSS 参考手册 HTML 在线测试工具 上面源码(博客园 - HTML): <style><!-- p.bg_gr ...
- 一种struts标签取不到值的情况
编写一个网页,使用<s:date >标签将日期格式化,使用了多组数据一直没有问题,突然在一组数据上死活出现不了数据了.程序如下 <s:iterator value="art ...
- centos配置nodejs和mysql
我使用的是centos7.2 64位,弄了一大晚上试了各种方法,安装的nodejs就是启动不了服务器.全是IP能ping通,浏览器不能访问.端口都是打开了的.安全组也设置了,就是不行.最后阿里云客服电 ...