分类:
.NET Core
//192.168开头的IP是一个代理Ip并不是你真实的IP
public string GetRelayIP()
{
WebClient myWebClient = new WebClient();
myWebClient.Credentials = CredentialCache.DefaultCredentials;
byte[] pageData = myWebClient.DownloadData("https://www.ip38.com/");
string pageHtml = Encoding.UTF8.GetString(pageData);
pageHtml = pageHtml.Replace('\'', '\"');
pageHtml = pageHtml.Replace("ip", "\"ip\"");
pageHtml = pageHtml.Replace("address", "\"address\"");
//根据返回会来的html进行切割 定位到ip
string pram = "<a href=/\"ip\".php?\"ip\"";
string[] arr = pageHtml.Split(pram.ToCharArray());
string strtempa = "=";
string strtempb = ">";
string ipstr = arr[1];
int IndexofA = ipstr.IndexOf(strtempa);
int IndexofB = ipstr.IndexOf(strtempb);
string ip = ipstr.Substring(IndexofA + 1, IndexofB - IndexofA - 1);
return ip;
}评价
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256
50010702506256
欢迎加群交流技术