C# 自动投票和手机号码归属地查询 - 简单程序源码分享(高手飘过)

本文提供了一个使用C#语言实现的自动投票程序及手机号码归属地查询源码,包括如何通过浏览器获取目标网址信息,并编写相应代码实现自动投票与查询功能。

C# 自动投票和手机号码归属地查询 - 简单程序源码分享(高手飘过) 

 

如有转载,请注明出处: http://www.cnblogs.com/sabby/archive/2012/01/01/2309675.html


C# 自动投票和手机号码归属地查询 - 简单程序源码分享(高手飘过)  


一、自动投票 

 

网上最近出现很多投票支持,今天在网上看到突发奇想要写一个简单程序自己刷,同时分享个手机号码归属地查询源程序代码,希望大家支持下小女的博客的第一个作品。

 

1.用Chrome打开 你想投票的网页,这里我以 http://ent.ifeng.com/tv/special/2012kuanian/ 为例,打开后按F12就可以下面网页的信息,如图:

 

 

 

点击网页上“我支持他”

 

 

点进去..

 

 

 

找到它请求的地址并打开像这样:

 

 

接下来开始写程序,代码如下:

using System;
using System.Windows.Forms;
namespace HnVote
{
     public  partial  class Form1 : Form
    {
         private  static  int _count;
         public Form1()
        {
            InitializeComponent();
            Timer timer =  new Timer {Interval =  1000};
            timer.Tick +=  new EventHandler(timer_Tick);
            timer.Start();
        }
         private  void timer_Tick( object sender, EventArgs e)
        {
            Text =  " 正在刷第  " + _count++ +  "  票... ";
            webBrowser1.Url =  new Uri( " http://survey.news.ifeng.com/accumulator_ext.php?key=http%3A%2F%2Fent.ifeng.com%2Ftv%2Fspecial%2F2012kuanian%2F%3F6%3Ft%3Dding&format=js&callback=ifeng_Ding_Handler.InitDingNum&extdata=ding_num_box6 ");
        }
    }
}

 

运行下:

 

 

二、 手机号码查询

 

它会自动不挺刷这个网页,看到这你们都懂了吧,下面再说说手机号码查询,这个跟刷票一样原理,前几部都要一样,同样用浏览器打开手机号码查询的网站,同以上步骤找到他调用的地址,最后编写代码如下:

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);
            }
        }
    }

}   


界面:


 

 

 

下面我提供源程序个大家下载,源码下载:http://www.ctdisk.com/file/3966695

好了,希望大家不要见笑,一个初学者的弱弱创作...


posted on 2012-01-01 22:57 sabby 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/sabby/archive/2012/01/01/2309675.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值