Using wget to download a file from a password protected link

限于喜欢 提交于 2019-12-05 01:53:08

问题


I am trying to use wget to download a file from a http link that is password protected. I am using the following syntax:

wget --http-user=user --http-password=xxxxxx http://......

Am I using the right syntax? Should user and password be surrounded by quotes or double quotes?


回答1:


I did this a few years ago and luckily found the script in a backup I still have.

I remember it was a two-stage process.

The first step is to get and store the cookie(s):

wget --keep-session-cookies --save-cookies nameofcookiesfile.txt --post-data 'email=my.email@address.com&password=mypassword123' https://web.site.com/redirectLogin -O login.html

The second is to use those cookies to get the file/page you need:

wget --load-cookies nameofcookiesfile.txt -p http://web.site.com/section/ -O savedoutputfile.html -nv

These are the commands exactly as I used them (except I have changed usernames, passwords, filenames and websites). I also came across this link which may be of some assistance particularly the "referer" part:

http://www.linuxscrew.com/2012/03/20/wget-cookies/

Hope this helps or at least gives someone a starting point.



来源:https://stackoverflow.com/questions/23761579/using-wget-to-download-a-file-from-a-password-protected-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!