获取外网ip地址

1. 搜狐

接口:http://pv.sohu.com/cityjson?ie=utf-8

返回:var returnCitySN = {"cip": "110.53.253.181", "cid": "430100", "cname": "湖南省长沙市"};

2. 淘宝(有点慢)

接口:http://ip.taobao.com/service/getIpInfo.php?ip=myip

返回:{"code":0,"data":{"ip":"110.53.253.181","country":"中国","area":"","region":"湖南","city":"长沙","county":"XX","isp":"联通","country_id":"CN","area_id":"","region_id":"430000","city_id":"430100","county_id":"xx","isp_id":"100026"}}

https://www.jianshu.com/p/8153bb06e7e2

https://blog.csdn.net/txz_gray/article/details/53217293

原文地址:https://www.cnblogs.com/pinweyshg/p/9505176.html

时间: 2024-07-28 16:43:08

获取外网ip地址的相关文章

c#获取外网IP地址的方法

1.如果你是通过路由上网的,可以通过访问ip138之类的地址来获取外网IP 2.如果是通过PPPOE拨号上网的,可以使用以下代码获取IP //获取宽带连接(PPPOE拨号)的IP地址,timeout超时(秒),当宽带未连接或者连接中的时候获取不到IP public static string GetIP_PPPOE(int timeout) { int i = timeout * 2; while (i > 0) { try { NetworkInterface[] nics = Network

MFC C++ 获取外网IP地址

#include <afxinet.h> //GB2312 转换成 Unicode wchar_t* GB2312ToUnicode(const char* szGBString) { UINT nCodePage = 936; //GB2312 int nLength=MultiByteToWideChar(nCodePage,0,szGBString,-1,NULL,0); wchar_t* pBuffer = new wchar_t[nLength+1]; MultiByteToWide

C# Winform程序获取外网IP地址

string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了 Uri uri = new Uri(strUrl); System.Net.WebRequest wr = System.Net.WebRequest.Create(uri); System.IO.Stream s = wr.GetResponse().GetResponseStream(); System.IO.StreamReader sr = new Sy

C#获取外网IP地址;C#获取所在IP城市地址

public static string GetIP() { using (var webClient = new WebClient()) { try { var temp = webClient.DownloadString("http://iframe.ip138.com/ic.asp"); var ip = Regex.Match(temp, @"\[(? <ip>\d+\.\d+\.\d+\.\d+)]").Groups["ip&qu

如何获取外网IP地址

常用手动查询方法是直接查询:http://www.ip138.com/ 代码实现方法如下: 方法I:C语言实现 //原理: 通过访问"http://city.ip138.com/ip2city.asp"解析返回内容 #include <urlmon.h> #pragma comment (lib,"Urlmon.lib") void GetBigIpAddress(char *szBuff) { if (NULL == szBuff || 0 == st

C#获取外网IP、本机MAC地址及Ping的实现

原文 获取外网IP, C#获取本机的MAC地址,C#通过编程方式实现Ping 获取外网IP地址 思路是通过WebRequest连接一些网上提供IP查询服务的网站,下载到含有你的IP的网页,然后用正则表达式提取出IP来 class Program { static void Main(string[] args) { Console.WriteLine(GetExportIP()); Console.ReadKey(); } public static string GetExportIP() {

linux获取外网ip

引言:目前获取ip的方法中,ifconfig和ip获取函数得到的都是内网ip.有时候需要获取外网ip,目前通用的做法,是向外部服务器发送请求,解析外部服务器响应,从而得到的自己的外网ip.linux下的 curl可以替我们完成这些工作,当然,不怕麻烦的话,可以自己分析http协议,自己实现以上过程.如果熟悉python的话,那就更简单了,就像我们所知道的,python总是有现成的库函数可供我们调用.一下总结几种获取外网ip的方法,以供查询,资料来源互联网. 参看资料: http://www.cn

shell脚本,提取ip地址和子网掩码,和查外网ip地址信息。

#提取IP地址和子网掩码 [[email protected] ~]# ifconfig eth0|grep 'inet addr'|awk -F'[ :]+' '{print $4"/"$8}' 192.168.16.110/255.255.255.0 [[email protected] ~]# #查外网IP地址 [[email protected] ~]# curl -s ipecho.net/plain;echo 114.93.99.39 #查外网ip地址是什么宽带<br

外网IP地址 内网 IP

外网IP地址 大部分网络使用B类或C类地址,每一个类的第一个八位组的范围如下: 1.0-—127.A类 网络号码范围是 0.0.0.0---127.0.0.0 ,用于128个网络.但网络不能全由0组成且127.0.0.0保留用于回路.剩下的126个网络,1到126,共有16777214个可能的主机地址(16777216减2) A类 网络 —主机—主机—主机 0-127 127 0 0 0 2.128—191.B类,网络号码范围是128.0.0.0--191.254.0.0 用于16256个网络.