各位大虾,我现在要做一个网站的登录页面。。  http://gd.10086.cn/  比喻说这个网站,我要自动填写,并且把验证码图片下载到本地来,我该怎么做,求大虾帮助

解决方案 »

  1.   

    参考:WinForm 登录CSDN
    http://blog.csdn.net/sxldfang/article/details/5651353
      

  2.   

    首先:登录成功之后,需要记录一些信息,比如用户名,记录在session,viewstate,cookie中
    winform中这些内容可以通过全局变量来记录问题出现了:你记录的这些变量怎么传递到你打开的浏览器呢,,并且,session,viewstate需要在web服务器上面有记录,,这个怎么处理 HtmlElement btnSubmit = webBrowser.Document.All["submitbutton"]; 
    HtmlElement tbUserid = webBrowser.Document.All["username"]; 
    HtmlElement tbPasswd = webBrowser.Document.All["password"]; if (tbUserid == null || tbPasswd == null || btnSubmit == null) 
      return; tbUserid.SetAttribute("value", "smalldust"); 
    tbPasswd.SetAttribute("value", "12345678"); btnSubmit.InvokeMember("click"); //输入用户名和密码 出发按钮click事件
      

  3.   

    这里有个自动填写用户名和密码的小例子//首先放一个WebBrowser控件在界面上,下面测试的url地址,
    string reg_url = "https://passport.baidu.com/?login&tpl=mn";//填表地址//这是Webbrowser的完成事件,检索用户名和密码的TextBox,进行填写
            private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                if (e.Url == webBrowser1.Document.Url && e.Url.ToString() == reg_url)//网页加载网且加载地址为填表地址
                {
                    webBrowser1.Document.GetElementById("username").SetAttribute("value", "user456"); //填写用户名                  for (int i = 0; i < 30; i++)
                    {
                        Thread.Sleep(100);
                        Application.DoEvents();
                    }
                    webBrowser1.Document.GetElementById("normModPsp").SetAttribute("value", "pwd123456");//填写密码
                    for (int i = 0; i < 30; i++)
                    {
                        Thread.Sleep(100);
                        Application.DoEvents();
                    }
                }          
            }
    最后找到按钮调用它的单击:InvokeMember("Click"); 
      

  4.   

    winform自动填写 可以用到文本框记忆功能
    验证码可以做成一个画布 
      

  5.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;namespace CsdnLogin
    {
        public partial class Form2 : Form
        {
            public Form2()
            {
                InitializeComponent();
            }               private void Form2_Load(object sender, EventArgs e)
            {
                webBrowser1.Url = new Uri("http://www.csdn.net/");
            }        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                HtmlElement txtUserHtml=webBrowser1.Document.All["username"];
                HtmlElement txtPasswordHtml = webBrowser1.Document.All["pwd"];
                HtmlElement btnClickHtml = webBrowser1.Document.All["Login"];            txtUserHtml.SetAttribute("value",txtUser.Text);
                txtPasswordHtml.SetAttribute("value", txtPwd.Text);
                btnClickHtml.InvokeMember("click");            Process.Start("http://www.csdn.net/");        }
        }
    }
      

  6.   

    http://blog.csdn.net/sxldfang/article/details/5651353
      

  7.   

    5楼说的是。这种用C/S来调用B/S的还真没做过。
      

  8.   

    你是要哪种方式?webbroweser 还是 httprequest? 验证码必须输入吧..现在有那么强的验证码识别么?
    webbrowser方式 楼上就可以了
    补充下读出webbrowser验证码图片的可以看这里
    http://blog.csdn.net/fish_8510/article/details/4802132
    httprequest模拟登陆的
    看http://blog.csdn.net/sxldfang/article/details/5651353
    确实挺全的