【问题标题】:Powershell Script to download a file from HTTPS website using用于从 HTTPS 网站下载文件的 Powershell 脚本
【发布时间】:2019-12-10 05:28:40
【问题描述】:

我需要每天从日期已过的网站下载文件。我尝试使用以下代码 -

$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 字符:1 + 调用-WebRequest -Uri $url -OutFile $output + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

【问题讨论】:

标签: powershell


【解决方案1】:

这是因为你的路径不是路径文件(你有一个'\'结束路径)

试试这个:

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

【讨论】:

    猜你喜欢
    • 2015-05-25
    • 1970-01-01
    • 2017-08-27
    • 2014-03-14
    • 2022-08-05
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    • 1970-01-01
    相关资源
    最近更新 更多