asp.net 手机号码所在地查询实现代码

用浏览器打开手机号码查询的网站,同以上步骤找到他调用的地址,最后编写代码如下:

 代码如下
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);
            }
        }
    }
}  
 

界面:


 

 

时间: 2024-08-02 21:27:02

asp.net 手机号码所在地查询实现代码的相关文章

WAP版的手机号码所在地查询

完成了一个简单有用的WAP网站--WAP版的手机号码所在地查询地址: http://hikey.net/wap 用支持wap的手机查看,不支持IE哈 如果你的手机不支持WAP或者不愿意那几分钱的话,可以用gelon.net提供的一个模拟器来看看我的作品 直接打开这个地址就可以了 http://www.gelon.net/cgi-bin/wapalize.cgi?url=http://hikey.net/wap //IE的编码要选择简体中文哈 //按滚轮下滑屏幕 wap上网按流量计费,我没用图片,

ASP处理多关键词查询实例代码

在web开发中经常遇到多关键词对对单个字段查询,我一般是通过动态数组来实现的.当然多个关键词的一般是用空格或,隔开,我这几假设多个关键词用空格隔开,关键字字符串为keyStr,具体代码为. 程序代码: 以下为引用的内容: '关键字的搜索 str="select * from tableName where id>4" if srhKey<>"" then keyArr=split(srhKey," ") j=UBound(key

ASP处理多关键词查询实例代码_应用技巧

程序代码: 复制代码 代码如下: '关键字的搜索 str="select * from tableName where id>4" if srhKey<>"" then keyArr=split(srhKey," ") j=UBound(keyArr) t=0 dim keystrArr() for i=0 to j if keyArr(i)<>"" then redim preserve key

Asp.Net类型转换类(通用类)代码分享_实用技巧

废话不多说了,直接给大家贴代码了,具体代码如下所述: /// <summary> /// 类型转换类 /// 处理数据库获取字段为空的情况 /// </summary> public static class DBConvert { #region------------------ToInt32类型转换------------------ /// <summary> /// 读取数据库中字符串并转换成Int32 /// 为空时返回0 /// </summary&

asp 完整google pr 查询程序

Google对PR查询加密后,ASP版的PR查询代码就很少见了,今天找到一个,给需要的站长,完整的代码如下: <%@LANGUAGE="JAVASCRIPT"%> <form name="zzsky" method="get" action=""> <input type="text" name="site"> <input type="

基于ASP实现QQ在线查询功能_应用技巧

本文给大家分享的qq在线查询功能代码非常简单,具体内容如下: 这段程序的方法是利用XMLHTTP来读取腾讯网站的相应HTML代码获取QQ的头像,根据这个想法,我们还可以抓取很多其他网站的信息,如天气预报.新闻等等. <script language="JavaScript"> <!-- function getFaceImg(QQcode) { var Re=new RegExp("^[1-9]{1}/d+$","g"); if

ASP.NET MVC 5 - 查询Details和Delete方法

原文:ASP.NET MVC 5 - 查询Details和Delete方法 在这部分教程中,接下来我们将讨论自动生成的Details和Delete方法. 查询Details和Delete方法 打开Movie控制器并查看Details方法. public ActionResult Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Movie movie

asp如何实现模糊查询,求助急在线等!!!!!

问题描述 <%varsqlwhere=Request.Form("textfield");varRecordset1=Server.CreateObject("ADODB.Recordset");Recordset1.ActiveConnection=MM_conn_ods_STRING;if(Request.Form("n")+"'"=="undefined'"){Recordset1.Source

初学MVC,哪个大神能帮忙讲一下这个三表查询的代码是什么意思?感谢!

问题描述 初学MVC,哪个大神能帮忙讲一下这个三表查询的代码是什么意思?感谢! var query3 = from q in db.Customers join qq in db.Orders on q.CustomerID equals qq.CustomerID into tmporder join e in db.Employees on q.City equals e.City into tmpemp select new { q.CompanyName, tmporderCount =