POST to website, save cookie, download website?
Hello, I have the following code which uses wget:
Code:
Process p;
Process r;
p = Runtime
.getRuntime()
.exec("wget -q -N https://www.supportspace.com:443/support/j_spring_security_check_online_account --post-data=\"j_username="
+ txtTestEmail.getText()
+ "&j_password="
+ passwordField.getText()
+ "&rememberMe=1\" --no-check-certificate --cookies=on --keep-session-cookies --save-cookies=cookie1.txt");
p.waitFor();
r = Runtime
.getRuntime()
.exec("wget -q -N --referer=http://www.supportspace.com/support.expert-account.s2 --cookies=on --load-cookies=cookie1.txt --keep-session-cookies --save-cookies=cookie1.txt http://www.supportspace.com/support/sessionHistory.s2");
r.waitFor();
Basically, the first part posts the username and password to that website and saves the cookie as cookie1.txt. Then the second part goes to the page that I actually want to retrieve which uses that cookie that was made to log into the website and download it and save it, and then the rest of my code parses that source code. But I want to convert this to be completely in java, because as you can imagine this currently is designed for windows, and I want it to work cross-platform. Any way to post login data to a website, keep the cookie, and then use that cookie to download a page from that website?
Thanks guys!
Re: POST to website, save cookie, download website?
Have you tried searching google? There are a ton of examples out there on how to hit a web site and how to pass parameters such as this one. Please check out of few of the many examples out there and post back if you have any questions on them.
Re: POST to website, save cookie, download website?
Quote:
Originally Posted by
ProgramThis
Have you tried searching google? There are a ton of examples out there on how to hit a web site and how to pass parameters such as
this one. Please check out of few of the many examples out there and post back if you have any questions on them.
I have seen how to use the POST method, but I have no idea how to save that cookie and then use is for another request.