类的代码如下:
1 using System; 2 using System.Net; 3 using System.Text.RegularExPRessions; 4 5 namespace Keleyi.Com 6 { 7 public class GetInternetIP 8 { 9 public static string GetIP()10 {11 using (var webClient = new WebClient())12 {13 try14 {15 var temp = webClient.DownloadString("http://iframe.ip138.com/ic.asp");16 var ip = Regex.Match(temp, @"/[(?<ip>/d+/./d+/./d+/./d+)]").Groups["ip"].Value;17 return !string.IsNullOrEmpty(ip) ? ip : null;18 }19 catch (Exception ex)20 {21 return ex.Message;22 }23 }24 }25 }26 }
http://www.VEVb.com/sosoft/
新闻热点
疑难解答