-
Read URL with delay
Hello,
my problem seems quite simple, but I have not yet found a suitable solution.
My problem is the following:
I need to log in to a secure website and retrieve a bit of information.
So far, logging in and going to the secure website is no problem and I get the html off it, but there is a problem. The site needs a minute to load my personal data and displays a "please while while your data is loaded" message. This is the one I get the html from.
My question to you is: How would I tell the program to go to an URL, wait 60 seconds before reading it and only then read it, thus successfully skipping the "loading data" message.
Any help is appreciated, example is appreciated too.
My current code:
Code:
//opening login site + adding data
...
//actually site I need
URL url2 = new URL("https://www.telenet.be/mijntelenet/telemeter/showUsage.do?identifier=w590990");
HttpURLConnection conn2 = (HttpURLConnection) url2.openConnection();
conn2.setRequestMethod("GET");
conn2.setDoInput(true);
conn2.setDoOutput(true);
writeCookies(conn2, true); //simply writes the login cookie I received to prove I'm logged in
conn2.connect();
BufferedReader in2 = new BufferedReader(new InputStreamReader(conn2.getInputStream()));
line = null;
while ((line = in2.readLine()) != null) {
System.out.println(line);
}
in2.close();
-
Thread.sleep(...)? java.util.Timer?
db
-
I've tried those already, same for setTimeout(), wait() and such
The problem seems so simple, yet it's been bugging me for days now ...
-
Try using the BufferedReader.ready() method to determine if the stream is ready to be read before reading, if not, then Thread.sleep(1000), then try again. Once it's ready, read it.
Ray
-
I suggest determining how the message and results are being displayed, which will let you know how to tackle the problem. Redirect (relatively simple)? Javascript (not so simple)? If javascript, you can wait however you wish, but the problem with updates from javascript lies in the fact that you can read the page any which way you want, without taking into account the scripting you will get the same answer.
-
Hey,
I think it's through javascript then. It probably gets my information from their database and then update the page with that information.
How can I take the javascript into account?