用浏览器打开手机号码查询的网站,同以上步骤找到他调用的地址,最后编写代码如下:
| 代码如下 | 复制代码 |
| using System; using System.Windows.Forms; using System.Xml; namespace HnVote { public partial class Mobile : Form { public Mobile() { InitializeComponent(); } private static string[] GetMobileInfo(string number) { try { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load("http://api.s*h*ow*ji.com/Locating/default.aspx?m=" + number); XmlNamespaceManager cx = new XmlNamespaceManager(xmlDocument.NameTable); cx.AddNamespace("content", "http://api.s*how*j*i.com/Locating/"); XmlNodeList nodes = xmlDocument.SelectNodes("//content:QueryResult|//content:Mobile|//content:Province|//content:City|//content:Corp|//content:Card|//content:AreaCode|//content:PostCode", cx); if (nodes.Count == 8) { if ("True".Equals(nodes[1].InnerText)) { return new string[] { nodes[0].InnerText, nodes[2].InnerText, nodes[3].InnerText, nodes[4].InnerText, nodes[5].InnerText, nodes[6].InnerText + nodes[7].InnerText }; } } return new string[] { "false" }; } catch (Exception) { return new string[] { "false" }; } } private void button1_Click(object sender, EventArgs e) { try { string[] num = GetMobileInfo(textBox1.Text); MessageBox.Show("所查号码:" + num[0] + "n归属省份:" + num[1] + "n归属城市:" + num[2] + "n城市区号:" + num[3] + "n城市邮编:" + num[4] + "n卡 类 型:" + num[5], "查询结果", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message,"错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); } } private void textBox1_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode==Keys.Enter) { button1_Click(sender,e); } } } } |
|
模拟极限越野
模拟极限越野开着大巴在各种奇葩路况里送乘客。山路弯道多得让人
模拟火车
模拟火车让你当回真正的火车司机,得先学会看信号灯、操作控制杆
可口的披萨美味的披萨
可口的披萨美味的披萨带您体验经营一家披萨店的乐趣。游戏画风温
定制虚拟偶像最新版
定制虚拟偶像最新版是一款超级经典有趣的日本模拟装扮类型的手游
病娇模拟器手机版正版(yandere simulator)
病娇模拟器最新版手游是一款萌妹二次元模拟游戏,玩家在游戏中可