比如http://www.sz800.com/sfz,这个网站,手工的操作方法为在身份证号码后面输入,之后点击快速查询,然后得出结果,但由于我手头有好几万个身份证要验证,想用程序来实现,请问:
如何用C#模拟这一过程,请高手帮帮忙,小弟这两天要向领导交差,不然就惨了

解决方案 »

  1.   

    用webbrowser控件访问http://www.sz800.com/sfz/index.asp?xian=身份证号码分析网页
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
      

  2.   

    webrequest请求url得到页面数据,提取你要的信息
      

  3.   

    这种机械式操作.你可以考虑使用按键精灵来帮你做.把要查的身份证放在一个EXCEL里,然后用按键精灵来做你重复执行... :-)这样更快.
      

  4.   

    请feiyun0112兄说清楚点,行不?我真的是不懂
      

  5.   


                //分析了一下网页的格式,
                //下面
                //提供一个思路,如果要查询几万条的话,速度肯定不行
                //我这里每次调用大概需要2秒钟
                //需要调用 WebClient.DownloadStringAsync 这个异步方法,
                //在回调方法中进行处理
                
                string careID = "320725197905231232";       //查询的号码            System.Net.WebClient client = new System.Net.WebClient();
                client.Encoding = System.Text.Encoding.Default;
                string reply = client.DownloadString( "http://www.sz800.com/sfz/index.asp?xian=" + careID );
                
                string city = string.Empty;     //原户籍地:
                string birthday = string.Empty; //出生年月:
                string sex = string.Empty;      //性    别:
                string msg = string.Empty;      //提示:            int iBegin = -1;     //开始位置
                int iEnd = -1;       //结束位置            iBegin = reply.IndexOf( "查询号码:" );
                if ( iBegin == -1 )
                {
                    //没查到信息,
                    //可以在循环中继续查询下一个号码
                    return;
                }            reply = reply.Substring( iBegin );      //取从 查询号码:开始到最后的内容            //原户籍地
                iBegin = reply.IndexOf( "原户籍地:" );
                iEnd = reply.IndexOf( "<br></td></tr>", iBegin );
                city = reply.Substring( iBegin, iEnd - iBegin );            //出生年月:
                iBegin = reply.IndexOf( "出生年月:" );
                iEnd = reply.IndexOf( "<br></td></tr>", iBegin );
                birthday = reply.Substring( iBegin, iEnd - iBegin );            //性别:
                iBegin = reply.IndexOf( "性&nbsp;&nbsp;&nbsp;&nbsp;别:" );
                iEnd = reply.IndexOf( "</td></tr>", iBegin );
                sex = reply.Substring( iBegin, iEnd - iBegin ).Replace( "&nbsp;", "" );            //提示信息
                iBegin = reply.IndexOf( "提示:" );
                iEnd = reply.IndexOf( "</td>", iBegin );
                msg = reply.Substring( iBegin, iEnd - iBegin );            MessageBox.Show( string.Format( "查询号码:{0}\n{1}\n{2}\n{3}\n{4}", careID, city, birthday, sex, msg ) );
      

  6.   

    完善一下            //分析了一下网页的格式,
                //下面
                //提供一个思路,如果要查询几万条的话,速度肯定不行
                //我这里每次调用大概需要2秒钟
                //需要调用 WebClient.DownloadStringAsync 这个异步方法,
                //在回调方法中进行处理
                
                string careID = "320621197905231235";       //查询的号码            System.Net.WebClient client = new System.Net.WebClient();
                client.Encoding = System.Text.Encoding.Default;
                string reply = client.DownloadString( "http://www.sz800.com/sfz/index.asp?xian=" + careID );
                
                string city = string.Empty;     //原户籍地:
                string birthday = string.Empty; //出生年月:
                string sex = string.Empty;      //性    别:
                string msg = string.Empty;      //提示:            int iBegin = -1;     //开始位置
                int iEnd = -1;       //结束位置            iBegin = reply.IndexOf( "查询号码:" );
                if ( iBegin == -1 )
                {
                    //没查到信息,
                    //可以在循环中继续查询下一个号码
                    return;
                }            reply = reply.Substring( iBegin );      //取从 查询号码:开始到最后的内容            //原户籍地
                iBegin = reply.IndexOf( "原户籍地:" );
                iEnd = reply.IndexOf( "<br></td></tr>", iBegin );
                city = reply.Substring( iBegin, iEnd - iBegin );            //出生年月:
                iBegin = reply.IndexOf( "出生年月:" );
                iEnd = reply.IndexOf( "<br></td></tr>", iBegin );
                birthday = reply.Substring( iBegin, iEnd - iBegin );            //性别:
                iBegin = reply.IndexOf( "性&nbsp;&nbsp;&nbsp;&nbsp;别:" );
                iEnd = reply.IndexOf( "</td></tr>", iBegin );
                sex = reply.Substring( iBegin, iEnd - iBegin ).Replace( "&nbsp;", "" );            //提示信息,有两种,一种是提示,说明号码有问题的
                //一种是“结果”,说明正确的
                iBegin = reply.IndexOf( "提示:" );
                if ( iBegin != -1 )
                {
                    iEnd = reply.IndexOf( "</td>", iBegin );
                    msg = reply.Substring( iBegin, iEnd - iBegin );
                }
                else
                {
                    iBegin = reply.IndexOf( "结果:" );
                    iEnd = reply.IndexOf( "</td>", iBegin );
                    msg = reply.Substring( iBegin, iEnd - iBegin );
                }
                MessageBox.Show( string.Format( "查询号码:{0}\n{1}\n{2}\n{3}\n{4}", careID, city, birthday, sex, msg ) );
      

  7.   

    我还是不懂,你们是如何得出网址后面的index.asp?xian=身份证号码
      

  8.   

    可以分析网页的源文件。获取这一段:<form action="index.asp" name=form1 method=post>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="37%" height="30" valign="middle" align=center>身份证号码:
               <input name=xian size=18 type=text>
                  <input name=submit type=submit value="快速查询"></td>
        </tr>
      </table>
    </form>如何你可以做这样一个含下面内容的框架:<form action="http://www.sz800.com/sfz/index.asp" name=form1 method=post>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="37%" height="30" valign="middle" align=center>身份证号码:
               <input name=xian size=18 type=text>
                  <input name=submit type=submit value="快速查询"></td>
        </tr>
      </table>
    </form>再做数据处理,应该可以的,你试试看。
      

  9.   

    你要分析那个网页的源码的,要知道ASP网页数据提交的几种方法