Java script, screen scraping, WebClinet.UploadData

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I posted this question previously and unfortunatly didn't get specific answer.

I have a problem with logging into web site via screen scraping. User name
and password field contain 'name' property, and therefore I can easily do
assignment to them: "userid=uidTest&password=pwTest"
User name and password are only required field names.

Submit button represented on page via hyper link:
<A href="javascript:login()" onBlur ="foc()"><IMG align=middle border=0
height=15 src="images/submit.gif" width=64></A>

Java script looks like this:
<script language=\"JavaScript1.2\">
function login()
{
document.login.method=\"post\";
document.login.action=\"/servlet/com.main.tmt.servlets.TmtLoginServlet\";
document.login.submit();
}
// end function
function foc() {
document.login.userid.focus();
}
</script>

How can I refer to it or invoke it?
For instance in case when I have html button with id btnSubmit and value
Submit, I would have following:
pParameters = "userid=uidTest&password=pwTest&btnSubmit=Submit";
_bParameters = Encoding.ASCII.GetBytes(pParameters);
_bResponse = _wc.UploadData(pURI, "POST", _bParameters);

I know that I have to post to the
"/servlet/com.main.tmt.servlets.TmtLoginServlet" url which mentioned in
JavaScript but what would be the syntax in c#?
Following is my c# code:
byte[] _bParameters = null;
byte[] _bResponse = null;
string _response = "";
pParameters = "userid=uidTest&password=pwTest"; // how to assign or execute
hyperlink?
_bParameters = Encoding.ASCII.GetBytes(pParameters);
_bResponse = _wc.UploadData(pURI, "POST", _bParameters);
_response = System.Text.Encoding.ASCII.GetString(_bResponse);

Thanks,
Victor
 
You can try SW Explorer Automation
(SWEA)(http://home.comcast.net/~furmana/SWIEAutomation.htm). It allows
to create an automation API to any Web application. SWEA supports
frames, html dialogs, popup dialogs, java script and wil work from
ASP.NET. It allows visually extract a Web page data using XPATH. You
can write the screen scraping solution in hours.
 
Back
Top