WLET -N的CURL中是否存在等效函数?

时间:2011-06-16 12:23:02

标签: windows linux curl

我想知道CURL是否允许您执行与WGET -N相同的功能 - 如果客户端上的现有文件比服务器上的旧文件旧,则只会下载/覆盖文件。

2 个答案:

答案 0 :(得分:2)

cURL没有与wget内置的相同类型的镜像支持。在cURL中有一个设置可以让你自己很容易实现这个,尽管有一点包装逻辑。这是--remote-time选项:

   -R/--remote-time
          When  used,  this  will  make  libcurl attempt to figure out the
          timestamp of the remote file, and if that is available make the
          local file get that same timestamp.

答案 1 :(得分:0)

我意识到这个问题现在已经很老了,但是以防万一有人在寻找答案,看来cURL确实可以达到类似于wget -N的目的。

因为我今天只是在寻找这个问题的答案,所以我在其他地方发现cURL确实具有时间条件选项。如果Google像我一样先把您带到这里,那么我希望这个答案可以为您节省一些时间。根据curl --help,有一个时间限制标志;

-z, --time-cond <time> Transfer based on a time condition

为了使它像wget -N一样,我需要的另一部分是使其尝试保存时间戳。这是带有-R选项的。

-R, --remote-time   Set the remote file's time on the local output

仅当当前本地“ $ file”时间戳早于服务器的文件时间戳时,才可以使用它们来下陷“ $ file”。我们可以以这种形式进行;

curl -R -o "$file" -z "$file" "$serverurl"

例如,我用它来检查是否有像这样的较新的cygwin安装程序;

curl -R -o "C:\cygwin64\setup-x86_64.exe" -z "C:\cygwin64\setup-x86_64.exe" "https://www.cygwin.com/setup-x86_64.exe"