窗体上放一个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

使用WebBrowser自动登录阿里妈妈网站的更多相关文章

  1. 开发Chrome插件,实现网站自动登录

    近期被一个事情困扰着,我们采购了一款软件,里面有一个数据大屏页,当登录过期后,数据就会保持原状,不再更新.和供应商反馈了很多次,都无法彻底解决数据显示的问题,没办法,自己周末在家研究,网站自动登录的事 ...

  2. iconfont阿里妈妈前端小图标使用方法详解

    图标选购网址:http://www.iconfont.cn/ 1.从阿里妈妈网站选购好小图标,加入购物车,下载好文件: 2.把字体文件放入字体(font)文件夹(tff)(woff),(eot) 3. ...

  3. C#_自动化测试1_模拟post,get_12306火车票网站自动登录工具

    还记得2011年春运,12306火车票预订网站经常崩溃无法登录吗. 今天我们就开发一个12306网站自动登录软件. 帮助您轻松订票 通过前两篇博客Fiddler教程和HTTP协议详解,我们了解了Web ...

  4. delphi webbrowser post自动登录

    delphi webbrowser post自动登录     var  EncodedDataString: WideString;  PostData: OleVariant;  Headers: ...

  5. python网络爬虫之使用scrapy自动登录网站

    前面曾经介绍过requests实现自动登录的方法.这里介绍下使用scrapy如何实现自动登录.还是以csdn网站为例. Scrapy使用FormRequest来登录并递交数据给服务器.只是带有额外的f ...

  6. 12306.cn网站自动登录器源代码

    去年过年放假的时候写了一个12306.cn网站的自动登录器,刚好那时候放假了,所以没把源代码放出来,现在将代码发出来,由于编写得比较仓促(从放假的下午19:00左右到晚上到00:00左右),很多细节问 ...

  7. Java 扫描微信公众号二维码,关注并自动登录网站

    https://blog.csdn.net/qq_42851002/article/details/81327770 场景:用户扫描微信公众号的二维码,关注后自动登录网站,若已关注则直接登录. 逻辑: ...

  8. 吴裕雄--天生自然PYTHON学习笔记:python自动登录网站

    打开 www. 5 l eta . com 网站,如果己经通过某用户名进行了登录,那么先退出登录 . 登录该网站 的步骤一般如下 : ( 1 )单击右上角的“登录”按钮. ( 2 )先输入账号. ( ...

  9. python模拟自动登录网站(urllib2)

    不登录打开网页: import urllib2 request = urllib2.Request('http://www.baidu.com') response = urllib2.urlopen ...

随机推荐

  1. pycharm pull到github

    1.setting中找到github 正确输入邮箱密码,勾上ssh 2.在本机中git bash 得到ssh代码 输入到github 个人setting中 3.在pycharm中setting项git ...

  2. java性能监控工具jps-windows

    jps Lists the instrumented Java Virtual Machines (JVMs) on the target system. This command is experi ...

  3. ES7前端异步玩法:async/await理解 js原生API妙用(一)

    ES7前端异步玩法:async/await理解   在最新的ES7(ES2017)中提出的前端异步特性:async.await. 什么是async.await? async顾名思义是“异步”的意思,a ...

  4. C# trim split dataGrid

    C#中Trim().TrimStart().TrimEnd()的用法:     这三个方法用于删除字符串头尾出现的某些字符.Trim()删除字符串头部及尾部出现的空格,删除的过程为从外到内,直到碰到一 ...

  5. PA-RISC

    http://baike.baidu.com/view/167703.htm PA-RISC处理器 编辑   HP(惠普)公司的RISC芯片PA-RISC于1986年问世. 第一款芯片的型号为PA-8 ...

  6. mysql (8.0 或以下)数据 卸载, 安装, 创建用户, 赋权

    卸载 安装 创建用户wmxl create user 'wmxl'@'202.115.253.71' identified by '你的密码' 如果是mysql8.0,再输入以下 ALTER USER ...

  7. CentOS minimal 安装ssh 服务 和客户端

      检查是否装了SSH包 如果现实有openssh-server 说明系统已经安装了ssh 2 如果系统没有安装ssh 那么可以在线安装 yum install openssh-server 3 设置 ...

  8. UVA1422-Processor(二分法+优先队列)

    option=com_onlinejudge&Itemid=8&category=512&page=show_problem&problem=4168"> ...

  9. Python--常用模块部分

    模块 pip install #模块名称 #安装模块 #导入模块 from collections import namedtuple collections模块 提供了几个额外的数据类型: Coun ...

  10. Kubernetes对象之Pod

    系列目录 Pod是Kubernetes调度的最小单元.一个Pod可以包含一个或多个容器,因此它可以被看作是内部容器的逻辑宿主机.Pod的设计理念是为了支持多个容器在一个Pod中共享网络和文件系统 因此 ...