如何了解我的客户端IP与.NET?我的、客户端、NET、IP

由网友(故笙诉离歌)分享简介:我需要从whatismyip.com客户端IP。但是,正则表达式是不正确的,我认为?你能帮我这个patttern?i need my client ip from whatismyip.com. But Regex pattern is not correct i think? Can you help me thi...

我需要从whatismyip.com客户端IP。但是,正则表达式是不正确的,我认为?你能帮我这个patttern?

i need my client ip from whatismyip.com. But Regex pattern is not correct i think? Can you help me this patttern?

推荐答案

这是可以实现的方式更容易使用从www.whatismyip.com自动化接口,所以没有必要对任何正则表达式:

This can be achieved way easier using the automation interface from www.whatismyip.com, so there's no need for any regex:

static void Main(string[] args)
    {
        const string url = "http://www.whatismyip.com/automation/n09230945.asp";

        var client = new WebClient();
        try
        {
            var myIp = client.DownloadString(url);
            Console.WriteLine("Your IP: " + myIp);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error contacting website: " + ex.Message);
        }
    }
阅读全文

相关推荐

最新文章