使用

时间:2019-08-01 15:07:46

标签: powershell

我需要每天从网站上下载文件,该日期将过去。我尝试使用以下代码-

$url = "https://www.theocc.com/webapps/threshold-securities?reportDate=20190730"
$output = "C:\Users\Himanshu.Vats\Downloads\"
Invoke-WebRequest -Uri $url -OutFile $output

但是它给出了错误-

  

Invoke-WebRequest:基础连接已关闭:发送中发生意外错误。       在第3行:char:1       +调用WebRequest -Uri $ url -OutFile $ output       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~           + CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-WebRequest],WebException           + FullyQualifiedErrorId:WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

1 个答案:

答案 0 :(得分:0)

这是因为您的路径不是路径文件(路径末尾有'\')

尝试一下:

$url = "https://www.theocc.com/webapps/threshold-securities?reportDate=20190730"
$output = "C:\Users\Himanshu.Vats\Downloads\result.csv"
Invoke-WebRequest -Uri $url -OutFile $output
相关问题