自动获取外网ip地址
using System;
using System.Net;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.Default;
string response = client.UploadString("http://iframe.ip138.com/ipcity.asp", "");
Match mc = Regex.Match(response, @"location.href=""(.*)""");
if (mc.Success && mc.Groups.Count > 1)
{
response = client.UploadString(mc.Groups[1].Value, "");
string[] str1 = response.Split('[');
response = str1[1];
string[] str = response.Split(']');
response = str[0];
Console.Write(response);
}
}
catch (System.Exception e)
{
}
Console.Read();
}
}
}
- 下一篇:unity3d 禁用脚本
- 上一篇:unity官方手册(高级)翻译(0)目录