Powershell - 为什么使用 Invoke-WebRequest 比浏览器下载慢得多? [英] Powershell - Why is Using Invoke-WebRequest Much Slower Than a Browser Download?

查看:81
本文介绍了Powershell - 为什么使用 Invoke-WebRequest 比浏览器下载慢得多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Powershell 的 Invoke-WebRequest 方法将文件从 Amazon S3 下载到我的 Windows EC2 实例.

I use Powershell's Invoke-WebRequest method to download a file from Amazon S3 to my Windows EC2 instance.

如果我使用 Chrome 下载文件,我可以在 5 秒内下载一个 200 MB 的文件.在 PowerShell 中使用 Invoke-WebRequest 进行相同的下载最多需要 5 分钟.

If I download the file using Chrome, I am able to download a 200 MB file in 5 seconds. The same download in PowerShell using Invoke-WebRequest takes up to 5 minutes.

为什么使用 Invoke-WebRequest 会变慢,有没有办法在 PowerShell 脚本中全速下载?

Why is using Invoke-WebRequest slower and is there a way to download at full speed in a PowerShell script?

推荐答案

我正在使用

Invoke-WebRequest $video_url -OutFile $local_video_url

我把上面的改成

$wc = New-Object net.webclient
$wc.Downloadfile($video_url, $local_video_url)

这将下载速度恢复到我在浏览器中看到的速度.

This restored the download speed to what I was seeing in my browsers.

这篇关于Powershell - 为什么使用 Invoke-WebRequest 比浏览器下载慢得多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆