我需要将文件下载到/tmp/cron_test/。我的wget代码是
wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/
那么是否有一些参数来指定目录?
我需要将文件下载到/tmp/cron_test/。我的wget代码是
wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/
那么是否有一些参数来指定目录?
当前回答
“-P”是正确的选项,请继续阅读以了解更多相关信息:
wget-nd-np-P/dest/dir—递归http://url/dir1/dir2
为方便起见,手册页中的相关片段:
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix. The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is . (the current directory).
-nd
--no-directories
Do not create a hierarchy of directories when retrieving recursively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the
filenames will get extensions .n).
-np
--no-parent
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.
其他回答
从手册页面:
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix. The directory prefix is the
directory where all other files and sub-directories will be
saved to, i.e. the top of the retrieval tree. The default
is . (the current directory).
因此,您需要在命令中添加-P/tmp/cron_test/(短格式)或--directory prefix=/tmp/cron _test/(长格式)。还要注意,如果目录不存在,则会创建该目录。
-O是指定要下载到的文件路径的选项:
wget <uri> -O /path/to/file.ext
-P是将下载目录中文件的前缀:
wget <uri> -P /path/to/folder
手册:-O文件--输出文档=文件
wget "url" -O /tmp/cron_test/<file>
确保下载的URL正确无误。首先,URL中包含以下字符:?并且这不能被解析和解析。这将混淆cmd行,并接受任何未解析为源URL名称的字符作为要下载到的文件名。
例如:
wget "sourceforge.net/projects/ebosse/files/latest/download?source=typ_redirect"
将下载到名为的文件中?source=类型_直接。
如您所见,了解一两个URL有助于理解wget。
我从租用者磁盘启动,只有Linux2.6.1作为资源(导入操作系统不可用)。解决我将ISO下载到物理硬盘上的问题的正确语法是:
wget "(source url)" -O (directory where HD was mounted)/isofile.iso"
您可以通过查找wget下载到名为index.html的文件(默认文件)中的时间点来确定正确的URL,并通过以下命令显示所需文件的正确大小/其他属性:
wget "(source url)"
一旦URL和源文件正确并且正在下载到index.html中,您可以停止下载(ctrl+z)并使用以下命令更改输出文件:
-O "<specified download directory>/filename.extension"
在源url之后。
在我的例子中,这导致下载一个ISO,并将其作为二进制文件存储在isofile.ISO下,希望可以安装。
“-P”是正确的选项,请继续阅读以了解更多相关信息:
wget-nd-np-P/dest/dir—递归http://url/dir1/dir2
为方便起见,手册页中的相关片段:
-P prefix
--directory-prefix=prefix
Set directory prefix to prefix. The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree. The default is . (the current directory).
-nd
--no-directories
Do not create a hierarchy of directories when retrieving recursively. With this option turned on, all files will get saved to the current directory, without clobbering (if a name shows up more than once, the
filenames will get extensions .n).
-np
--no-parent
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.