您的位置:首页 > 其它

访问网页并自动填写表单

2016-02-05 16:46 459 查看
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;
namespace webfullform

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }
        private void Form1_Load(object sender, EventArgs e)

        {
        }
        private void button1_Click(object sender, EventArgs e)

        {
        }
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

        {

            HtmlDocument htmlDoc = webBrowser1.Document;

            HtmlElement ImageButton1 = htmlDoc.All["ImageButton1"];

            HtmlElement txAccount = webBrowser1.Document.All["txAccount"];

            HtmlElement txPwd = webBrowser1.Document.All["txPwd"];

            if (ImageButton1 != null)

            {

                txAccount.SetAttribute("value", "wlq");

                txPwd.SetAttribute("value", "wlq");

                //ImageButton1.InvokeMember("click");

                //btnElement.AttachEventHandler("onclick", new EventHandler(HtmlBtnClose_Click));

            }

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: