得到真實外網IP IP所在國家 省份 地區

2021-09-08 02:15:19 字數 1490 閱讀 8520

實現方式:通過正則抓取ip顯示**中的資料。。。。

#region##得到真實ip以及所在地詳細資訊    

//////

得到真實ip以及所在地詳細資訊(porschev)

//////

public

string getipdetails()

(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)

"; //

ip正則

string ip = string.empty; //

ip位址

string country = string.empty; //

國家

string adr = string.empty; //

省市

string html = gethtml(url); //

得到網頁原始碼

regex reg = new regex(regstr, regexoptions.none);

match ma = reg.match(html); html = ma.value;

regex ipreg = new regex(ipregstr, regexoptions.none);

ma = ipreg.match(html);

ip = ma.value; //

得到ip

int index = html.lastindexof("

:") + 1;

country = html.substring(index); //

得到國家

adr = getadrbyip(ip);

return

"ip:

" + ip + "

國家:" + country + "

省市:" + adr;

}

#endregion

#region##通過ip得到ip所在地省市

//////

通過ip得到ip所在地省市(porschev)

//////

///public

string getadrbyip(string ip)

#endregion

#region##獲取html原始碼資訊

//////

獲取html原始碼資訊(porschev)

//////

獲取位址

///html原始碼

public

string gethtml(string url)

#endregion

得到真實外網IP IP所在國家 省份 地區

region 得到真實ip以及所在地詳細資訊 得到真實ip以及所在地詳細資訊 porschev public string getipdetails 2 0 4 d 25 0 5 01 d d?ip正則 string ip string empty ip位址 string country strin...

獲取與外網通訊的真實ip位址

define str defaulthost www.sohu.com char getipbyindex int nindex if dwretval getadaptersinfo padapterinfo,uloutbuflen no error padapter padapter next ...

JavaWeb專案中得到訪問者的真實ip

web專案中得到訪問者的真實ip 描述 最近要實現個功能是要記錄管理員登入的真實ip,但在專案中如果直接使用request.getremoteaddr 獲得ip的話,獲得的可能不是真實ip,是因為使用 的一些原因,所以我們要自己找個方法,具體方法如下 public class utils if ip...