Automatic Web Page Use With .NET
Automatic Web Page Use With .NET
Written by Ian Elliot   
Wednesday, 28 August 2013
Article Index
Automatic Web Page Use With .NET
Accessing the data
Complete Program Listing

The Complete Program

This program isn't included in the codebin because it is very specific to the website it targets and therefore can't actually be run. 

The full listing of the program as described is:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace NetUse
 public partial class Form1 : Form
  private int page;
  private WebBrowser webBrowser1;
  public Form1()


  private void makeBrowser()
   webBrowser1 = new System.Windows.
   webBrowser1.Name = "webBrowser1";


  private void showBrowserInForm()
   webBrowser1.Location = new    
           System.Drawing.Point(12, 300);
   webBrowser1.MinimumSize = new
           System.Drawing.Size(20, 20);
   webBrowser1.Size = new
           System.Drawing.Size(783, 338);
   webBrowser1.TabIndex = 1;

  private void button1_Click(
           object sender,
           EventArgs e)

   page = 1;
   webBrowser1.DocumentCompleted += new    
   webBrowser1.Navigate("login URL");

  private void login()
   HtmlElement name = webBrowser1.Document.
   if (name != null)
     name.InnerText = "User name";

   HtmlElement password =webBrowser1.
   if (password != null)
     password.InnerText = "password";
   HtmlElement submit = webBrowser1.
   if (submit != null)


  private void gotoData()
   webBrowser1.Navigate("URL of Data Page");

  private void getData()
   string text = webBrowser1.DocumentText;
   Regex ex1 = new
   string used = ex1.Match(text).
   textBox1.Text = used;


  void DocumentCompleted(
           object sender,    
    WebBrowserDocumentCompletedEventArgs e)
   if ( webBrowser1.ReadyState!=
     WebBrowserReadyState.Complete) return;
   switch (page)
    case 1:
     page = 2;
    case 2:
     page = 3;
    case 3:
     page = 4;



Related Articles:
Hit Highlighting with dtSearch
Automating applications using messages


blog comments powered by Disqus


To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+Twitter, Linkedin or Facebook or sign up for our weekly newsletter.



Getting Started With Azure Linux VMs

If you are a Visual Studio user there are lots of advantages to making use of Azure as your Virtual Machine host. In this article the general ideas of using Azure and how to work with Linux VMs is des [ ... ]

SNTP time class

SNTP is a network protocol for obtaining an accurate time and it is an interesting exercise to build an SNTP client. In this article the language used is C# but it is easy enough to generalise to a la [ ... ]

Other Projects




Last Updated ( Thursday, 16 January 2014 )

RSS feed of all content
I Programmer - full contents
Copyright © 2015 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.