views:

29

answers:

2

Hi Experts,

I need to login to a website with username and password, and then download a file. The url of the file is static. How do I automate the above process with Linux/Unix scripts? Thanks a lot.

Jiangzhe

+2  A: 

well, it's not that simple. what you need to do is the following:

  • send an HTTP POST request containing your username and password to the login form's URL.
  • you will get a cookie (probably containing a session ID).
  • send an HTTP GET request for the file, sending your cookie details in the HTTP headers.

you probably should use some scripting language with an HTTP library (python's httplib and urllib2 are great options).

ozk
Thanks, I'll have a try on the libraries you mentioned.
A: 

Just use CURL to send POST or GET request with login data to site and then do second request to download file.

Māris Kiseļovs