Link to home
Start Free TrialLog in
Avatar of lez60
lez60

asked on

Redirecting to new page after loging using HttpsURLConnection

I have following task:
1. login to yahoo
2. after successful login go to finance.yahoo.com
3. parse some information e.g. stock quote
4. I want to repeat operation each 5 minutes to get the same , refreshed page, so do I have to re-establish connection or reuse existing one with refresh mechanizm ?

I was able to finish 1. connect but result looks like this:
<html>
<head>
<script language="JavaScript">
<!--
window.location.replace("http://finance.yahoo.com");
// -->
</script>
<meta http-equiv="Refresh" content="0; url=http://finance.yahoo.com">
</head>
<body>
If you are seeing this page, your browser settings prevent you
from automatically redirecting to a new URL.
<p>
Please <a href="http://finance.yahoo.com">click here</a> to continue.
</body>
</html>



so it looks, after login i am not redirecting but in my code
I am using HttpsURLConnection.setFollowRedirects(true);
so It shoud work. My guess is , that javscript is not executed.

thanks in advance for any help


Lez
 
Avatar of hoomanv
hoomanv
Flag of Canada image

not sure but use
window.location="http://finance.yahoo.com";
instead
setFollowRedirects() should be invoked before url.openConnection() otherwise it wont work then you have to call setInstanceFollowRedirects()
man, dont you think that HttpUrlConnection doesn't parse the html content and it cant understand javascript ? you need to do it manualy
ASKER CERTIFIED SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial