首先我们每个人都想查对方的手机所在地及属于什么类型卡,那我们利用C#封装的类WebClient,NameValueCollection,Regex等分别属于的命名空间是using System.Net、using System.Text、using System.Collections.Specialized、using System.Text.RegularExpressions。是在Vs2005环境下测试,下面代码测试如下:
 1 private void InitWeaOne()
 2   {
 3       WebClient wb = new WebClient();
 4       NameValueCollection myNameValueCollection = new NameValueCollection();
 5
 6       myNameValueCollection.Add("mobile""13777483912");
 7       myNameValueCollection.Add("action""mobile");
 8       byte[] pagedata = wb.UploadValues("http://www.ip138.com:8080/search.asp", myNameValueCollection);
 9       string result = Encoding.Default.GetString(pagedata);
10       string pat = "tdc2>([^<]*)</TD>";
11       Regex r = new Regex(pat, RegexOptions.IgnoreCase);
12       Match m = r.Match(result);
13       string[] strInfo = new string[3"""""" };
14       int i = 0;
15       while (m.Success)
16       {
17           if (i < strInfo.Length)
18           {
19               strInfo[i] = m.ToString().Substring(5);
20           }

21           m = m.NextMatch();
22           i++;
23       }

24       string a = strInfo[0].ToString();
25       string g = strInfo[1].ToString();
26       string f = strInfo[2].ToString();
27   
28  }
posted on 2007-07-11 16:40  阳春  阅读(1337)  评论(11)    收藏  举报