熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

asp.net 手機號碼所在地查詢實現代碼

2022-06-13   來源: .NET編程 

  用浏覽器打開手機號碼查詢的網站同以上步驟找到他調用的地址最後編寫代碼如下

  代碼如下
using System;
using SystemWindowsForms;
using SystemXml;
namespace HnVote
{
    public partial class Mobile : Form
    {
        public Mobile()
        {
            InitializeComponent();
        }
        private  static string[] GetMobileInfo(string number)
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocumentLoad("+ number);
                XmlNamespaceManager cx = new XmlNamespaceManager(xmlDocumentNameTable);
                cxAddNamespace("content" "
                XmlNodeList nodes = xmlDocumentSelectNodes 

  ("//content:QueryResult|//content:Mobile|//content:Province|//content:City|//

  content:Corp|//content:Card|//content:AreaCode|//content:PostCode" cx);
                if (nodesCount == )
                {
                    if ("True"Equals(nodes[]InnerText))
                    {
                        return new string[]
                                   {
                                       nodes[]InnerText nodes[]InnerText nodes[]InnerText nodes[]InnerText
                                       nodes[]InnerText nodes[]InnerText + nodes[]InnerText
                                   };
                    }
                }
                return new string[] { "false" };
            }
            catch (Exception)
            {
                return new string[] { "false" };
            }
        }
        private void button_Click(object sender EventArgs e)
        {
            try
            {
                string[] num = GetMobileInfo(textBoxText);
                MessageBoxShow("所查號碼" + num[] + "n歸屬省份" + num[] + "n歸屬城市" + num[] + "n城市區號" + num[] + "n城市郵編" +
                                num[] + "n卡 類 型" + num[] "查詢結果" MessageBoxButtonsOK MessageBoxIconInformation);
            }
            catch (Exception ex)
            {
                MessageBoxShow(exMessage"錯誤提示"MessageBoxButtonsOKMessageBoxIconWarning);
            }
        }
        private void textBox_KeyDown(object sender KeyEventArgs e)
        {
            if(eKeyCode==KeysEnter)
            {
                button_Click(sendere);
            }
        }
    }
}  
 

  界面

  asp.net 手機號碼所在地查詢實現代碼

  
 


From:http://tw.wingwit.com/Article/program/net/201311/14406.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.