zoukankan      html  css  js  c++  java
  • 使用WebBrowser自动登录阿里妈妈网站

    窗体上放一个WebBrowser,其Url属性设置为http://www.alimama.com/membersvc/member/login.htm,其他属性为默认

    再放一个Button,默认

    Button按钮的代码如下(方法一)

    view plaincopy to clipboardprint?
    private void button1_Click( object sender, EventArgs e )  
    {  
        System.Windows.Forms.HtmlDocument document =this.webBrowser1.Document;  
        if ( document == null )  
        {  
            return;  
        }  
        document.All["logname"].SetAttribute( "Value", "用户名" );            //用户名  
        document.All["originalLogpasswd"].SetAttribute( "Value", "密码" );      //密码  
        document.All["dologin"].InvokeMember( "click" );    //登录按钮的click方法        

            private void button1_Click( object sender, EventArgs e )
            {
                System.Windows.Forms.HtmlDocument document =this.webBrowser1.Document;
                if ( document == null )
                {
                    return;
                }
                document.All["logname"].SetAttribute( "Value", "用户名" );            //用户名
                document.All["originalLogpasswd"].SetAttribute( "Value", "密码" );      //密码
                document.All["dologin"].InvokeMember( "click" );    //登录按钮的click方法     
            }

    方法二

    view plaincopy to clipboardprint?
    private void button1_Click( object sender, EventArgs e )  
    {  
        System.Windows.Forms.HtmlDocument document =this.webBrowser1.Document;  
        if ( document == null )  
        {  
            return;  
        }  
        document.All["logname"].SetAttribute( "Value", "用户名" );            //用户名  
        document.All["originalLogpasswd"].SetAttribute( "Value", "密码" );      //密码  
     
        document.All["dologin"].RaiseEvent( "onClick" );        //登录按钮的click事件  
        document.All["formRegStep1Main"].InvokeMember( "submit" );  //提交表单  

            private void button1_Click( object sender, EventArgs e )
            {
                System.Windows.Forms.HtmlDocument document =this.webBrowser1.Document;
                if ( document == null )
                {
                    return;
                }
                document.All["logname"].SetAttribute( "Value", "用户名" );            //用户名
                document.All["originalLogpasswd"].SetAttribute( "Value", "密码" );      //密码
         
                document.All["dologin"].RaiseEvent( "onClick" );        //登录按钮的click事件
                document.All["formRegStep1Main"].InvokeMember( "submit" );  //提交表单
            }

    测试环境:WinXp(SP2)、VS2008用

    转自sdfkfkd

    成功网站案例(时尚淘女之家): http://www.tao36524.com/ 

     

  • 相关阅读:
    Oracle常见故障问题
    java前后端加密(转载)
    美团在Redis上踩过的一些坑-3.redis内存占用飙升(转载)
    tomcat访问(access)日志配置、记录Post请求参数(转)
    angular2学习资源汇总
    Ionic2 常见问题及解决方案
    URL Schemes(转载)
    (四)文本编辑器Vim/Vi
    C#接口作用的深入理解
    C#连接SQL Server数据库进行简单操作
  • 原文地址:https://www.cnblogs.com/hfzsjz/p/1692751.html
Copyright © 2011-2022 走看看