powershell - 用于从 HTTPS 网站下载文件的 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 :底层连接已关闭:发送时发生意外错误。在 line:3 char:1 + Invoke-WebRequest -Uri $url -OutFile $output + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
解决方案
这是因为您的路径不是路径文件(您有一个 '\' 结束路径)
尝试这个:
$url = "https://www.theocc.com/webapps/threshold-securities?reportDate=20190730"
$output = "C:\Users\Himanshu.Vats\Downloads\result.csv"
Invoke-WebRequest -Uri $url -OutFile $output
推荐阅读
- python - 如何在模型中实现 t-SNE?
- eos - 错误 3070003:序列化错误处理 WASM
- typescript - 如何处理 javascript 包中的版权声明?
- oracle - 2 个并发事务中的行数
- java - 如何在多个招摇页面中公开我的 Rest 服务。
- hive - 由于失败,第二个配置单元查询失败:ParseException 行 5:101 在第一个配置单元查询中缺少 EOF
- java - 带有小胡子的 Java Spring 一直在服务器上查找文件
- extjs - Extjs 侦听器不适用于 6.2.1 现代工具包
- python - 返回列中的值不是日期类型的数据框行
- javascript - 在 Boostrap 4 Popover 中禁用翻转