There is an internal site at work that is hosted on a different server than most of the internal sites. The site outputs some information that I want to obtain via screen scraping. I've done screen scraping using an asp.net (C#) page and an HTTPWebRequest on other internal sites, but unlike most, this site requires a username and password.The username and password are not a secret, they are posted along side the login page and everyone uses the same login info.
I've seen some examples on the web that accomplish automatic login, but none of those are were quite what I need. I want to use an aspx page to login to the site and retrieve some data from the next page.
The examples I've seen involve generating a cookie and posting the login data to the HTTPWebRequest Stream. I'm really not sure how to do this in this case.
Is it possible to simply populate the form fields and execute the submitw button (programatically and behind the scenes).
Here is a portion of the code for the login page:
<script>
//StartTranslate:NetLanguage
function window_onload() {
deleteCookie("BodyURL","/Net",0);
document.loginform.UserName.focus();
document.loginform.UserName.value=sUserName;
document.loginform.UserName.select();
}
function doSubmit() {
var sUserName = SMCookieGetUserName();
loginform.submit();
}
</script>
<form name="loginform" action="/Net//netportal.dll/SubmitLogin" method="post" >
<input class="textbox" type="text" name="UserName" id="UserName" maxlength="128" tabindex="1" >
<input class="textbox" type="password" name="Password" id="Password" maxlength="128" tabindex="2" >
<img onClick="doSubmit();" src='/net/PortalPages/Images/slogin.gif' onselectstart="return false;" tabindex="3">
<input type="hidden" value="" name="Timezone">
<input type="hidden" value="" name="redirect">
<input type="hidden" value="true" name="ExplicitLogin">
</form>