I have a problem..
I want to download to XML some info from website ( this I know how to do ), i know how to dl info from website but problem is when first
i need to log in.
Its part of code:
<form method="post" action="logowanie.php">
<table class="center">
<tr>
<td><label for="username">Login:</label></td>
<td><input type="text" name="username" value=""></td>
<td rowspan="2"><div class="submit"><input type="submit" value="OK" name="submit"></div></td>
</tr>
<tr>
<td><label for="password">Hasło:</label></td>
<td><input type="password" name="password" value=""></td>
I need to some how enter username password and press button submit.
Any ideas , code samples how to do it ?
Thanks very much.
Im doing it in Java/Scala.
While the Apache
HttpClientwould work, using it from Scala is unidiomatic and verbose, and the Dispatch library provides a nice Scala wrapper that lets you write much more concise code. You could use it like this:This example would simply print the response, but you can easily provide more sophisticated ways of handling the response, and your
clientnow holds the cookies you need to continue interacting with the site.Here’s a more complex example that I’ve used to log in to a system that required me to pick up a generated identifier from the form before logging in:
Here I’m using Dispatch’s JSoup support to parse the form page and pull out the identifier I need, which I can then add to the form parameters when I submit the request.