使用wget下载图片失败_使用WGET

使用wget下载图片失败

Wget is a tasty utility on Linux and Mac OS X systems that can come in handy for web system administrators.

Wget在Linux和Mac OS X系统上是一个不错的实用程序,可以方便Web系统管理员使用。

Wget — found on the GNU.org site — is a command line application for file retrieval over ftp, http and https connections.

Wget( 位于GNU.org网站上 )是一个命令行应用程序,用于通过ftp,http和https连接进行文件检索。

I find it useful for downloading files directly to a server I am working on in a shell session, saving time instead of downloading to my local desktop and uploading. Additionally, since it can pass user names and passwords, it is powerful for use in web site migrations, setting up mirrored sites and more.

我发现它对于将文件直接下载到我在Shell会话中正在处理的服务器上非常有用,从而节省了时间,而不是将其下载到本地桌面并上传。 此外,由于它可以传递用户名和密码,因此在网站迁移,设置镜像站点等方面功能强大。

Finally, Wget can be scheduled using cron, so if a file or directories need replicated on a regular basis, it can be set to do so without adminstrator intervention.

最后,可以使用cron计划Wget,因此,如果需要定期复制文件或目录,可以将其设置为无需管理员干预。

Some useful examples for utilizing Wget:

一些利用Wget的有用示例:

1) Downloading a remote file – Perhaps you are downloading an update to an application and have been sent the url. In this case you could use either ftp or http to retrieve:

1)下载远程文件–也许您正在将更新下载到应用程序并已发送了URL。 在这种情况下,您可以使用ftp或http来检索:

wget http://somedomain.com/public/remotefilename.tar.gz or wget ftp://somedomain.com/public/remotefilename.tar.gz

wget http://somedomain.com/public/remotefilename.tar.gz or wget ftp://somedomain.com/public/remotefilename.tar.gz

Wget over ftp defaults to binary (i mode on ftp lingo), however, of you need to use ascii mode, you simply add ‘;type=a’ (without quotes) onto the end of the ftp url example above.

Wget over ftp默认为二进制(在ftp术语上为i模式),但是,在需要使用ascii模式的情况下,您只需在上述ftp url示例的末尾添加'; type = a'(不带引号)即可。

2) Downloading with authentication – you may be updating a registered application requiring a user name and password to access. Change the syntax as shown below:

2)通过身份验证下载–您可能正在更新注册的应用程序,需要用户名和密码才能访问。 更改语法,如下所示:

wget username:password@http://somedomain.com/reg/remotefilename.tar.gz or wget username:password@ftp://somedomain.com/reg/remotefilename.tar.gz

wget username:password@ http://somedomain.com/reg/remotefilename.tar.gz or wget username:password@ ftp://somedomain.com/reg/remotefilename.tar.gz

3) Inserting custom ports into the wget request – perhaps your download will require a custom port along with authentication. Wget easily handles this as well by inserting a colon and portnumber afrter the host and before the /path to file(s):

3)在wget请求中插入自定义端口-也许您的下载将需要一个自定义端口以及身份验证。 Wget可以通过在主机之后以及文件的/ path之前插入一个冒号和端口号来轻松地处理此问题:

wget username:password@http://somedomain.com:portnumber/reg/remotefilename.tar.gz or wget username:password@ftp://somedomain.com:portnumber/reg/remotefilename.tar.gz

wget username:password@ http://somedomain.com:portnumber/reg/remotefilename.tar.gz or wget username:password@ ftp://somedomain.com:portnumber/reg/remotefilename.tar.gz

4) Entire directories can also be migrated from one server to another, i.e. moving a web site to new hardware. I have found ftp access to be most effective for this. I also make use of logging (the -o option) the transfer in the event debugging or verification of file retrieval is needed, and use the recursive option (-r) to recreate the directory structure on the new server.

4)整个目录也可以从一台服务器迁移到另一台服务器,即将网站移至新硬件。 我发现ftp访问对此最有效。 我还利用日志记录(-o选项)在需要调试或验证文件检索的事件中进行传输,并使用递归选项(-r)在新服务器上重新创建目录结构。

So if I am moving mydomain.com — I would use:

因此,如果我要移动mydomain.com,请使用:

wget -o mylogfile -r myuser:mypass@ftp://mydomain.com/

wget -o mylogfile -r myuser:mypass@ ftp://mydomain.com/

If you have an ftp user that can see more than one domain, insure you specify the path to the files and directories for the domain you are moving.

如果您的ftp用户可以看到多个域,请确保为要移动的域指定文件和目录的路径。

There are several other interesting and useful options including:

还有其他一些有趣且有用的选项,包括:

–passive-ftp: for using wget behind firewalls

–passive-ftp:用于在防火墙后面使用wget

-nd: does not recreate the directory structure on the remote machine and instead simply saves all retrieved files into the current local directory.

-nd:不会在远程计算机上重新创建目录结构,而只是将所有检索到的文件保存到当前本地目录中。

–cookies=on/off: if the remote site requires cookies to be on or off to retireve files (helpful with authentication at times)

–cookies = on / off:如果远程站点要求打开或关闭cookie以检索文件(有时有助于身份验证)

–retr-symlinks: Will retrieve files pointed to by symbolic links.

–retr-symlinks:将检索符号链接指向的文件。

There are several other powerful features in Wget, and fortunately, the manual included offers excellent examples. Simply run man wget on the command line to review.

Wget中还有其他一些强大的功能,所幸的是,随附的手册提供了出色的示例。 只需在命令行上运行man wget进行检查。

翻译自: https://www.sitepoint.com/using-wget/

使用wget下载图片失败

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值