【问题标题】:wget error when trying to download files尝试下载文件时出现 wget 错误
【发布时间】:2018-04-21 08:42:59
【问题描述】:

我正在尝试使用 wget 从网站下载文件,我尝试了我在网上找到的这个命令:

wget -r -l1 -H -t1 -nd -N -np -A.zip -erobots=off https://website.name/mydownloads.php

我在我的一个文件夹中启动了,并在那里使用了该命令,但它返回:

Invoke-WebRequest : Cannot bind parameter 'Headers'. Cannot convert the "-t1" value of type "System.String" to type "Sy
stem.Collections.IDictionary".
At line:1 char:13
+ wget -r -l1 -H -t1 -nd -N -np -A.zip -erobots=off https://website.na ...
+             ~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

这是因为我没有正确安装 wget 还是我做错了什么?

【问题讨论】:

  • 使用wget.exe - 否则你正在调用PowerShells Invoke-Webrequest(正如它在你的错误消息中所说)。搜索 SO 的原因。已经回答了几十次了。
  • 从哪里启动 PowerShell?它找不到 wget.exe,但我不知道它在我的电脑上的位置@Swonkie
  • wget.exe 是第 3 方应用程序。它在 Linux 系统上无处不在。

标签: powershell powershell web wget


【解决方案1】:

您给出的命令是 wget.exe 命令,而不是 PowerShell 'wget' 命令。

PowerShell 为 Invoke-WebRequest 定义了一个别名 wget,因此如果您的系统上有 wget.exe,您仍然需要键入路径或至少 .exe 扩展名来绕过别名:

wget.exe -r -l1 -H -t1 -nd -N -np -A.zip -erobots=off https://website.name/mydownloads.php

或

C:\PathTOwget\wget -r -l1 -H -t1 -nd -N -np -A.zip -erobots=off https://website.name/mydownloads.php

您可以在此处获取适用于 Windows 的 Gnu wget.exe:

http://gnuwin32.sourceforge.net/packages/wget.htm

您可以通过大量的单字母开关最容易地判断这是一个 wget.exe 示例,但最明确的是带有 =off 的开关和 PowerShell 不使用的一起运行 .zip 开关(对我来说也是如此,多年使用 wget.exe 程序)。

或者,您可以尝试将其转换为 PowerShell invoke-webrequest,但其中一些开关在 Invoke-WebRequest 中没有直接模拟。

【讨论】:

    猜你喜欢
    • 2011-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多