访问网页并自动填写表单

来源:互联网 发布:大麦盒子dm1001网络锁 编辑:程序博客网 时间:2024/05/22 14:00
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));
            }
        }
    }
}
0 0