开发者

script that automatically logs in a website and download a file

开发者 https://www.devze.com 2023-01-11 05:32 出处:网络
I need to login to a website with开发者_JS百科 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

I need to login to a website with开发者_JS百科 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


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).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消