本文介绍了在wget-ing之前获取文件的文件大小到wget?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法提前检查可以通过 wget 下载的文件大小?我知道,使用 - spider 选项告诉我一个文件是否存在,但我也有兴趣找到该文件的大小。

I'm wondering if there is a way to check ahead of time the size of a file I might download via wget? I know that using the --spider option tells me if a file exists or not, but I'm interested in finding the size of that file as well.

推荐答案

对我来说 - spider 会显示大小:

$ wget --spider http://henning.makholm.net/
Spider mode enabled. Check if remote file exists.
--2011-08-08 19:39:48--  http://henning.makholm.net/
Resolving henning.makholm.net (henning.makholm.net)... 85.81.19.235
Connecting to henning.makholm.net (henning.makholm.net)|85.81.19.235|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9535 (9.3K) [text/html]     <-------------------------
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.

$ 

(但请注意,并非所有网络服务器都会通知客户数据的长度,除非通过在所有连接被发送时关闭连接)。

(But beware that not all web servers will inform clients of the length of the data except by closing the the connection when it's all been sent).

如果你担心wget会改变格式,报告长度,可以使用 wget --spider --server-response 并在输出中查找 Content-Length 标题。

If you're concerned about wget changing the format it reports the length in, you might use wget --spider --server-response and look for a Content-Length header in the output.

这篇关于在wget-ing之前获取文件的文件大小到wget?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 20:35