2

How can I port this wget stuff to scala:

wget --keep-session-cookies --save-cookies cookies.txt --post-data 'password=xxxx&username=zzzzz' http://server.com/login.jsp
wget --load-cookies cookies.txt http://server.com/download.something

I want to write a tiny, portable script, no external libraries etc.

Can that be done easily ?

Bastl
  • 2,926
  • 5
  • 27
  • 48

1 Answers1

2

Your two main requirements appear to be:

  • Auth with some body text
  • Maintain the session cookies between requests.

Since Scala itself doesn't have much support for HTTP in the core library besides scala.io.Source, you're pretty much stuck with HttpUrlConnection from the Java itself. Looks like this site already has some examples of using HttpUrlConnection in ways like this: Reusing HttpURLConnection so as to keep session alive

Community
  • 1
  • 1
Sean Parsons
  • 2,832
  • 21
  • 17
  • see here for a newbie example: http://docs.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/accessingCookies.html – Bastl Jul 23 '12 at 07:38