我正在尝试使用wget从我的AWS ubuntu服务器下载apache2。 我已经尝试了几个不同的选项,但都是由目录名称或index.html文件导致的文件。
目录中有3张图片和一个ogg格式的video。
这是我正在使用的wget:
wget -N -np http://domainorIP/dir/dir2/dirtodownload/
默认情况下, wget只会下载您提供的URL,而不是从HTML页面链接的任何资源。 要遵循这些链接,您需要-r (或--recursive )选项。
还有下载--page-requisites选项,它下载显示你给它的页面所需的任何资源,比如内联图像和样式表。
还有“分组”选项,如--mirror ,其中包括-r以及其他几个对镜像有用的选项。
手册页是巨大的,因为wget有很多function。 Recursive Retrieval Options将是非常值得的时间来阅读。
下载CLI浏览器并下载所需的文件,您可以使用ELinks或W3M
apt-get install elinks w3m
我从来没有成功获得curl或wget来下载从Apache服务器提供indexing directories启用的文件。 我想这也是你的问题。 当你浏览它们时,这些目录就会显示出来:

在Apache中,它们是这样启用的:
<Directory /var/www/domain.com/pdfs> Options Indexes FollowSymLinks </Directory>
使用shell你的select限于获取文件列表,然后使用像这样的命令一次下载一个:
% URL="http://www.lamolabs.org/blog/wp-content/uploads/2012/10/" % curl -s $URL | \ grep "href" | \ grep -v "C=D;O=A" | \ sed "s#^.*href=\"#$URL#" | \ sed 's/">.*$//' | \ xargs wget
打破这个:
- URL="..." - is the URL I want to download files from - curl -s $URL - get's the contents of the index.html generated by Apache - grep "href" - get lines that contain only href - grep -v "C=D;O=A" - eliminate the header bar line generated by Apache - sed "s#^.*href=\"#$URL#" - replace .*href=" lines with URL - sed 's/">.*$//' - remove trailing characters >.*$ - xargs wget - download each file using wget
您可以将其作为单个命令运行:
url="http://www.lamolabs.org/blog/wp-content/uploads/2012/10/"; curl -s $url | grep "href" | grep -v "C=D;O=A" | sed "s#^.*href=\"#$url#" | sed 's/">.*$//' | xargs wget
运行它会导致下载的文件被下载:
% ls -l total 1652 -rw-rw-r-- 1 saml saml 1351400 Oct 8 23:35 Anatomy-of-the-Linux-file-system.mht -rw-rw-r-- 1 saml saml 485 Oct 11 00:42 eratosthenes_prime_sieve.pl_.txt -rw-rw-r-- 1 saml saml 27191 Oct 3 21:42 Selection_005-150x150.png -rw-rw-r-- 1 saml saml 24202 Oct 3 21:42 Selection_005.png -rw-rw-r-- 1 saml saml 27141 Oct 3 21:42 Selection_006-150x150.png -rw-rw-r-- 1 saml saml 24906 Oct 3 21:42 Selection_006.png -rw-rw-r-- 1 saml saml 25783 Oct 3 22:17 Selection_007-150x150.png -rw-rw-r-- 1 saml saml 111915 Oct 3 22:17 Selection_007-650x180.png -rw-rw-r-- 1 saml saml 48109 Oct 4 09:57 Selection_007-e1349359020755.png -rw-rw-r-- 1 saml saml 29336 Oct 3 22:17 Selection_007.png