POST to website, save cookie, download website?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: POST to website, save cookie, download website?

  1. #1
    Join Date
    Jan 2008
    Posts
    4

    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!

  2. #2
    Join Date
    Feb 2008
    Posts
    966

    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.

  3. #3
    Join Date
    Jan 2008
    Posts
    4

    Re: POST to website, save cookie, download website?

    Quote Originally Posted by ProgramThis View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center