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

  • 相关阅读:
    MySQL(2)---Explain
    MySQL(1)---索引
    php 的 PHPExcel1.8.0 使用教程
    通过html5 的EventSource来进行数据推送
    centos6.6 下 安装 php7 按 nginx方式
    IIS PHP Warning: Unknown: open(c:\php\tmp\sess_xxx, O_RDWR) failed: Permission denied (13) in Unknown on line 0
    动态加载JS,并执行回调函数
    nginx 504 gateway time out
    php 账号不能同时登陆,当其它地方登陆时,当前账号失效
    php 函数中静态变量的问题
  • 原文地址:https://www.cnblogs.com/xumaojun/p/8529210.html
Copyright © 2011-2022 走看看