博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何用wget指定位置?
阅读量:3576 次
发布时间:2019-05-20

本文共 2369 字,大约阅读时间需要 7 分钟。

我需要将文件下载到/ tmp / cron_test /。 我的代码是

wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/

那么是否有一些参数来指定目录?


#1楼

从手册页:

-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/ (长格式)。 另请注意,如果目录不存在,则会创建该目录。


#2楼

试试这个方法 -

import ospath = raw_input("enter the url:")fold = raw_input("enter the folder:")os.system('wget -r -nd -l1 -P %s --no-parent -A mp3 %s'%(fold, path))

#3楼

-O是指定要下载的文件的路径的选项。

wget 
-O /path/to/folder/file.ext

-P是将在目录中下载文件的前缀

wget 
-P /path/to/folder

#4楼

确保您所下载的内容的URL正确无误。 首先,带有字符的网址? 这样就无法解析和解决。 这将混淆cmd行并接受未解析为源URL名称的任何字符作为要下载的文件名。

例如:

wget "sourceforge.net/projects/ebosse/files/latest/download?source=typ_redirect"

将下载到名为?source=typ_redirect的文件中。

如您所见,了解一两个关于URL的内容有助于理解wget

我从一个hirens磁盘启动,只有Linux 2.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 "
/filename.extension"

在源网址之后。

在我的情况下,这导致下载ISO并将其存储为isofile.iso下的二进制文件,希望能够安装。


#5楼

man wget:-O file --output-document = file

wget "url" -O /tmp/cron_test/

#6楼

“-P”是正确的选择,请继续阅读以获取更多相关信息:

wget -nd -np -P / dest / dir --recursive

为方便起见,手册页中的相关摘要:

-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.

转载地址:http://zrogj.baihongyu.com/

你可能感兴趣的文章
Hive学习(八)函数
查看>>
Hive学习(九)企业级调优
查看>>
MySQL 5.6 Keywords and Reserved Words(关键字和保留词)
查看>>
阿里云函数计算 使用Python开发一个基于WSGI的HTTP触发器 (实战)
查看>>
JSQLParser 解析 sql select 字段(含对别名的解析)
查看>>
如何在win10 下同时使用32位和64的eclipse
查看>>
MyBatis (五)一级缓存和二级缓存的区别
查看>>
MyBatis (六)结合多线程实现模拟缓存
查看>>
Oracle样例数据库(SCOTT)的SQL查询题
查看>>
Oracle程序题之:夺冠球队
查看>>
EL获取url传递的参数,并且根据参数设置弹出框
查看>>
Oracle中sum函数和case when联合使用,报“ORA-00923: 未找到要求的 FROM 关键字”错误
查看>>
SpringMVC(一) 国际化实现及原理
查看>>
JAVA多线程(一) 创建线程的三种方式
查看>>
MyBatis(七) 解决resultMap只返回一条结果的问题
查看>>
GOF(一) 代理模式(Proxy pattern)
查看>>
web面试题整理
查看>>
MyBatis+Spring+SpringMVC框架面试题整理(一)
查看>>
MyBatis+Spring+SpringMVC框架面试题整理(二)
查看>>
MyBatis面试题 如何构建一个线程安全的SqlSession
查看>>