WebBrowser automatically fills in and captures webpage data

Source: Internet
Author: User

This is a c # programming. You can check it at will.

Well, what I will show you next is to automatically fill in the data and log on to the 126 mailbox, which also captures data;

Although this is very simple, it can also be used as a reference for me. I am writing an example here. I will rely on myself to further understand it. Haha start:

Figure 1.0 jump to the 126 logon page

Code:

Code

 // Go to the page
Private void button#click (object sender, EventArgs e)
{
If (comboBox1.SelectedIndex = 0)
MessageBox. Show ("Please select a URL! ");
Else
{
Timer1.Enabled = true;
This. webBrowser1.Navigate (comboBox1.Text); // jump to the corresponding page
This. webBrowser1.IsWebBrowserContextMenuEnabled = true;

}
}

Figure 1.1 capture data

When you do not enter the password or user name, it will give you a prompt. Here we will take the prompt information:

 

Code

 // 126 log on
Private void button3_Click (object sender, EventArgs e)
{
// Fill in the account
WebBrowser1.Document. GetElementById ("iptUser"). InnerText = textBox2.Text. Trim ();
// Fill in the password
WebBrowser1.Document. GetElementById ("iptPwd"). InnerText = textBox3.Text. Trim ();
// Call the logon button click event
WebBrowser1.Document. GetElementById ("enter. x"). InvokeMember ("click ");
// Obtain the prompt information
String ts = webBrowser1.Document. GetElementById ("error_div"). InnerText;
If (ts! = "")
MessageBox. Show (ts );
}

Here, the "iptUser" in the Code GetElementById ("iptUser") is the user name text box on the webpage page. In this step, the textBox is used. the value in text is filled in the text box with the ID "iptUser" in the webpage;

// Call the logon button click event
WebBrowser1.Document. GetElementById ("enter. x"). InvokeMember ("click ");

This row calls the "click" event of the button with the ID "enter. x;

Figure 1.2 Web Page code in the browser

 

Figure 1.3 logon successful

 

Bytes ------------------------------------------------------------------------------------------------

End! In fact, there is basically no amount of code, and it is easy to understand.

Tip: After you watch the video, please leave your valuable comments and suggestions,

Reprint of friends please indicate the original from http://www.cnblogs.com/song_ thank you!

Finally, I hope this article will give you some insights!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.