Programmtically Fill in a form?

  • Thread starter Thread starter Anil Gupte/iCinema.com
  • Start date Start date
A

Anil Gupte/iCinema.com

How can programmatically I fill in a form on a web page in VB? This is in a
desktop program and I am using Webclient right now to get info on a page.
In some cases it asks me to login and I want it to be automatic.

Any suggestions welcome.

Thanx,
 
Anil said:
How can programmatically I fill in a form on a web page in VB? This is in a
desktop program and I am using Webclient right now to get info on a page.
In some cases it asks me to login and I want it to be automatic.

If you fill in a form on a "web page" and submit that then a HTTP
request is made that sends the form data. You can do that with WebClient
or with WebRequest, check the HTML document of the page to find out the
control names in the form, the action URI attribute to submit to and the
request method (e.g. GET or POST), then program the corresponding
request with WebClient or WebRequest.

WebClient has methods like this
http://msdn.microsoft.com/en-us/library/900ted1f.aspx to make a GET or
POST request with a collection of data.
 
Thanx Martin:
I got a little further as you suggested. I was already using WebClient, so
was able to follow a link using

Dim WCInstance As WebClient = New WebClient
returnValue = WCInstance.DownloadData(ItemURL)

then parse that page and follow the signon link. Now when I get to the
login form I have:

<form name="loginForm" id="loginForm" method="post">
<input type="hidden" name="current_form" value="loginForm" />

so there is nothing poiting to a URL to submit to and the submit button uses
JavaScript to submit:

<div class="action-button" style="" id="button-signin">
<a id="button-signin-link" href='#'
onclick='document.getElementById("loginForm").submit(); return false;'>
Sign In</span></div>
<div class="end-cap img-action-button-cap-right"></div>
</a>
</div>
<input type="hidden" name="action_login" value="Log In">

I am not sure how to proceed. Please advise.
 
Back
Top