使用 wget 从受密码保护的链接下载文件 [英] Using wget to download a file from a password protected link
问题描述
我正在尝试使用 wget 从受密码保护的 http 链接下载文件.我正在使用以下语法:
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://......
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?
推荐答案
几年前我做过这个,幸运的是在我仍然拥有的备份中找到了脚本.
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.
第一步是获取和存储 cookie:
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
第二种是使用那些cookies来获取你需要的文件/页面:
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.
这篇关于使用 wget 从受密码保护的链接下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!