用浏览器打开手机号码查询的网站,同以上步骤找到他调用的地址,最后编写代码如下:
代码如下 | 复制代码 |
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.showji.com/Locating/default.aspx?m=" + number); XmlNamespaceManager cx = new XmlNamespaceManager(xmlDocument.NameTable); cx.AddNamespace("content", "http://api.showji.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); } } } } |
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级