110,534
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
string phoneNum = tbPhoneNum.Text;
try
{
//web客户端
WebClient webclient = new WebClient();
//下载数据
string str_ = webclient.DownloadString("http://www.ip138.com:8080/search.asp?mobile=" + phoneNum + "&action=mobile");
//正则
string str_regex = "><!-- <td></td> -->.*</TD>";
//忽略大小写
Regex regex = new Regex(str_regex, RegexOptions.IgnoreCase);
//开始匹配
MatchCollection matchCollection = regex.Matches(str_);
txtAddress.Text = "卡归属地:" + matchCollection[0].Value.Replace("><!-- <td></td> -->","").Replace("</TD>","");
txtType.Text = "卡类型:" + matchCollection[1].Value.Replace("><!-- <td></td> -->", "").Replace("</TD>", "");
}
catch (Exception ex) { }
}