使用wget从受密码保护的链接下载文件 [英] Using wget to download a file from a password protected link

查看:762
本文介绍了使用wget从受密码保护的链接下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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: p>

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

第二个是使用这些cookie来获取您需要的文件/页面:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆