automating a web process

  • Thread starter Thread starter Janet Heath
  • Start date Start date
J

Janet Heath

Everyday, sometimes several times a day, I get on a website, login and
check for parttime jobs to accept. Would like to automate this
process so that I don't have to be on the system so much. I have
experience programming in VB .NET but nothing like this. Can this be
done? If so, any ideas?


Janet
 
I do something like that with the WebBrowser control (in
System.Windows.Forms). First, I go to the web site (with Internet Explorer,
in my case) and look at the HTML code to find the name tags for the input
controls on the web form. Then, I write the program to navigate to the web
site that has the form, then loop through the HTML elements in the
Document.All property of the browser. When I find an element with the
TagName property is "INPUT", I check the Id property for the input field
names, then set the InnerText property to the value that I want to input.
After I have all the input fields set, I loop through the elements to find
one with the TagName of "FORM", then I call the element's InvokeMember
method with an argument of "Submit".

Once the following page loads, I read through the HTML of the document in
the WebBrowser and scrape out the data that I want to use.

There's some reasonably useful sample code at the MSDN library under the
WebBrowser control that might be helpful, too.

Thank you so much Jack for your info. The form is in an .asp program.


Janet
 
You're quite welcome. The ASP will send HTML to the browser control, so that
by itself isn't a problem. However, you may get multiple pages in the
DocumentCompleted event of the browser control, because ASP servers often
send intermediate pages to a web clilent. Most browsers don't show the
intermediate URL's so you don't normally see them. Make sure you scane the
document for what you're looking for, and if the forms aren't there, wait
for another DocumentCompleted event.

Ok.

Here is the code that I get when I do view source on the Login Page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script language="Javascript">
if (window !=top) top.location.href = location.href;

var LogSaveOnLoad = window.onload;
window.onload = LogInit;

function LogInit()
{
// Set focus to the client id or last name input.
var form = document.forms[0];
if (form)
{
if (form.ClientID)
{
form.ClientID.focus();
}
else if (form.LastName)
{
form.LastName.focus();
}
}

if (LogSaveOnLoad)
{
LogSaveOnLoad();
}
}

function CheckPassWord(pinfield, clientid)
{
if(clientid && clientid.length == 0)
{
alert("District ID can not be blank. Please try again.");
return false;
}

var valid =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

if(pinfield.length == 0)
{
alert("PIN can not be blank. Please try again.");
return false;
}

for (var i=0; i < pinfield.length; i++)
{
temp = "" + pinfield.substring(i, i+1);
if (valid.indexOf(temp) == "-1")
{
alert("You can only use numeric numbers and letters in your pin.
Please try again!");
return false;
}
}

return true;
}
</script>


<html>
<head>



<title>SubFinder</title>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<link href="../wc2.css" type="text/css" rel="stylesheet">
</head>


<body leftMargin="0" topMargin="0" rightmargin="0" bottommargin="0"
style="padding: 0px; margin: 0px">


<form name="frmLogin" method=post action="../login/loginpage.asp"
onSubmit="return CheckPassWord(frmLogin.PinNumber.value, null)"
ID="Form2">


<TABLE class="Login" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="LoginLeft"></td>
<td class="LoginRight">
<DIV class="LoginLogo"><IMG src="../images/loginlogo.gif"
align="left"></DIV>
<DIV class="TitleDiv">
<DIV class="TitleLine">
<DIV class="Title" id="TitleDiv" Runat="server"></DIV>
</DIV>
<DIV class="TitleEnd"></DIV>
</DIV>
<DIV class="LoginFields">
<DIV class="LoginError"><span id="ErrorMessage"
style="color:Red;"></span></DIV>
<table id="LogOnTable" cellspacing="0" cellpadding="0" border="0"
style="border-width:0px;border-collapse:collapse;">

<tr class="LoginRow">
<td nowrap>
<span class="LoginLabel">Last Name</span>
</td>
<td>
<input name="LastName" type="text" id="LastName"
class="LoginTextBox" maxlength="50" />
</td>
<td>&nbsp;</td>
</tr>
<tr class="LoginRow">
<td nowrap>
<span class="LoginLabel">Password</span>
</td>
<td>
<input name="PinNumber" type="password" id="PinNumber"
class="LoginTextBox" maxlength="9" />
</td>
<td><input type="image" name="Submit" id="Submit"
class="LoginSubmit" src="../images/login_submit.gif"
onmouseover="this.src='../images/login_submit-over.gif'"
onmouseout="this.src='../images/login_submit.gif'" alt="" border="0"
style="background-color:Transparent;" /></td>
</tr>
</table></DIV>
<DIV class="LoginContact"><font size=4>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
St. Vrain Valley School District<br>
<br>
<font size=3>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
For log in problems or questions, please contact <br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
the Substitute Coordinator at 303-682-7393.<br>
</font>
</DIV>
</DIV>
</td>
</tr>
<tr>
<td colspan=2>
<DIV class="Copyright">SubFinder © Copyright CRS Incorporated
1995-2008. All Rights
Reserved.</DIV>
</td>
</tr>
</TABLE>
<INPUT name="Res800x600" type=Hidden value="0">
</form>

</body>

<script language=javascript>

if(screen.width < 1024)
{
document.forms[0].Res800x600.value = 1;
}
//alert(document.forms[0].Res800x600.value);
</script>

</html>
 
Back
Top