找回密码
 新建账号

The response content cannot be parsed because the Internet Explorer engine is not available

[复制链接]
蔡徐坤 发表于 2023/12/14 00:29 | 显示全部楼层 |阅读模式
The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launchconfiguration is not complete. Specify the UseBasicParsing parameter and try again.

在 Windows Server Core 中运行 curl 或者 Invoke-WebRequest,会出现以上错误。

其实出现这个错误,原因很明显,就是 Windows Server Core 操作系统中没有 Internet Explorer,只有 C:\Program Files\Internet Explorer 和 C:\Program Files (x86)\Internet Explorer 两个空文件夹,文件夹里面没有任何文件,没有安装过 Internet Explorer 就会报错。
  1. Get-ChildItem -Path "C:\Program Files\Internet Explorer" -Force -Recurse
复制代码
  1. Get-ChildItem -Path "C:\Program Files (x86)\Internet Explorer" -Force -Recurse
复制代码
解决方法已经在错误信息里面说了,就是使用 -UseBasicParsing 这个开关参数。

当然,也可以使用真正的 curl,使用 curl.exe 来访问链接,Windows Powershell 的 curl 是一个假的 curl,而且和真的 curl 参数也不一样,返回结果也不一样,Powershell 6.0 开始已经被删除了,删除的只是 curl 这个别名命令,Invoke-WebRequest 继续沿用,Windows 系统自带的 Powershell 一直是 Windows Powershell 5.1 和更低的版本。

Powershell 文档中有关于 -UseBasicParsing、Internet Explorer、Windows Server Core 的说明。
-UseBasicParsing
Indicates that the cmdlet uses the response object for HTML content without Document Object Model (DOM) parsing. This parameter is required when Internet Explorer is not installed on the computers, such as on a Server Core installation of a Windows Server operating system.
不过,Powershell 文档又说了,从 Powershell 6.0 开始所有请求都 Use Basic Parsing 了,-UseBasicParsing 只是为了兼容性才保留了下来,给了这个参数也不起作用,很显然,现实并不是这样,在没有 Internet Explorer 的操作系统上这个参数还那么一点用处。
-UseBasicParsing
This parameter has been deprecated. Beginning with PowerShell 6.0.0, all Web requests use basic parsing only. This parameter is included for backwards compatibility only and any use of it has no effect on the operation of the cmdlet.
参考链接 Powershell:Invoke-WebRequest curl

手机版|轻松E站

GMT+8, 2024/4/28 03:52

快速回复 返回顶部 返回列表