由于 Internet Explorer 引擎不可用,无法解析响应内容,或者

2024-03-15

我需要使用 powershell 下载频道 9 系列,但是我尝试过的脚本有错误:

  1. 这个脚本

    $url="https://channel9.msdn.com/blogs/OfficeDevPnP/feed/mp4high"
    $rss=invoke-webrequest -uri $url 
    $destination="D:\Videos\OfficePnP"
    [xml]$rss.Content|foreach{ 
      $_.SelectNodes("rss/channel/item/enclosure") 
    }|foreach{ 
        "Checking $($_.url.split("/")[-1]), we will skip it if it already exists in $($destination)"
      if(!(test-path ($destination + $_.url.split("/")[-1]))){ 
        "Downloading: " + $_.url 
        start-bitstransfer $_.url $destination 
      } 
    }
    

    失败并出现错误:

    无法解析响应内容,因为Internet Explorer引擎不可用,或者Internet Explorer的首次启动配置不完整。指定 UseBasicParsing 参数并重试。

  2. 我也尝试过这个

    # --- settings ---
    $feedUrl = "https://channel9.msdn.com/blogs/OfficeDevPnP/feed/mp4high"
    $mediaType = "mp4high"
    $overwrite = $false
    $destinationDirectory = join-path ([Environment]::GetFolderPath("MyDocuments")) "OfficeDevPnP"
    
    # --- locals ---
    $webClient = New-Object System.Net.WebClient
    
    # --- functions ---
    function PromptForInput ($prompt, $default) {
     $selection = read-host "$prompt`r`n(default: $default)"
     if ($selection) {$selection} else {$default}
    }
    
    function DownloadEntries {
     param ([string]$feedUrl) 
     $feed = [xml]$webClient.DownloadString($feedUrl)
    
     $progress = 0
     $pagepercent = 0
     $entries = $feed.rss.channel.item.Length
     $invalidChars = [System.IO.Path]::GetInvalidFileNameChars()
     $feed.rss.channel.item | foreach {
        $url = New-Object System.Uri($_.enclosure.url)
        $name = $_.title
        $extension = [System.IO.Path]::GetExtension($url.Segments[-1])
        $fileName = $name + $extension
    
        $invalidchars | foreach { $filename = $filename.Replace($_, ' ') }
        $saveFileName = join-path $destinationDirectory $fileName
        $tempFilename = $saveFilename + ".tmp"
        $filename
        if ((-not $overwrite) -and (Test-Path -path $saveFileName)) 
        {
            write-progress -activity "$fileName already downloaded" -status "$pagepercent% ($progress / $entries) complete" -percentcomplete $pagepercent
        }
        else 
        {
            write-progress -activity "Downloading $fileName" -status "$pagepercent% ($progress / $entries) complete" -percentcomplete $pagepercent
           $webClient.DownloadFile($url, $tempFilename)
           rename-item $tempFilename $saveFileName
        }
        $pagepercent = [Math]::floor((++$progress)/$entries*100)
      }
    }  
    
    # --- do the actual work ---
    [string]$feedUrl = PromptForInput "Enter feed URL" $feedUrl
    [string]$mediaType = PromptForInput "Enter media type`r`n(options:Wmv,WmvHigh,mp4,mp4high,zune,mp3)" $mediaType
    $feedUrl += $mediaType
    
    [string]$destinationDirectory = PromptForInput "Enter destination directory" $destinationDirectory
    
    # if dest dir doesn't exist, create it
    if (!(Test-Path -path $destinationDirectory)) { New-Item $destinationDirectory -type directory }
    
    DownloadEntries $feedUrl
    

    有太多错误

    http://screencast.com/t/bgGd0s98Uc http://screencast.com/t/bgGd0s98Uc


在您的调用 Web 请求中只需使用参数-UseBasicParsing

例如在你的脚本(第2行)中你应该使用:

$rss = Invoke-WebRequest -Uri $url -UseBasicParsing

根据文档 https://learn.microsoft.com/en-us/previous-versions/powershell/module/Microsoft.PowerShell.Utility/Invoke-WebRequest?view=powershell-3.0,在未安装或配置 IE 的系统上此参数是必需的:

使用 HTML 内容的响应对象,无需文档对象模型 (DOM) 解析。当计算机上未安装 Internet Explorer 时(例如在 Windows Server 操作系统的服务器核心安装上),需要此参数。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

由于 Internet Explorer 引擎不可用,无法解析响应内容,或者 的相关文章

  • IE 中带有“删除”方法的 jQuery.ajax 问题

    我有一个页面 用户可以使用按钮编辑各种内容并选择触发 ajax 调用 特别是 一个操作会导致远程调用一个 url 其中包含一些数据和 放置 请求 这 因为我使用的是宁静的 Rails 后端 会触发我的更新操作 我还有一个删除按钮 它调用相同
  • Powershell 调用程序集委托

    我有一个用于过程控制应用程序的 dll 程序集 我在我的内部使用 load电源外壳 script 该DLL包含我需要使用的委托类型 委托名称是 X Y Delegate 我在该 DLL 中有另一个方法 应该这样调用 Method deleg
  • Azure 函数核心工具安装卡在 Visual Studio Code 中

    我创建了 Azure 函数应用程序来执行 powershell 脚本 想先在我的本地运行它来测试它 当我运行它时 无论有没有调试选项 都会出现一个弹出窗口 其中显示 您必须安装 Azure Functions 核心工具才能调试本地函数 当我
  • ParseFromString 在 IE 中抛出错误,但在 Chrome 中不会抛出错误

    我正在使用传单的 KML 插件 该插件在 Google Chrome 中运行良好 然而 在 IE 中 它会在以下代码中引发错误 parser new DOMParser console log url outputs path to kml
  • 正确配置JDK环境变量后仍然找不到java命令

    我在 Windows 虚拟机启动时安装 JDK 使用 cloudinit 用户数据将 PowerShell 脚本传输到 Windows 计算机 然后运行该脚本来安装 JDK softwares Get ItemProperty HKLM S
  • .NET WebBrowser 控件可以使用 IE9 吗?

    我意识到这是一个早期版本并且不稳定 我不会梦想在任何其他项目中将默认的 Web 浏览器控件替换为 IE9 但在这种情况下 我特别需要 IE9 与其他版本进行比较 我想让 NET WebBrowser 控件使用 IE9 而不是机器上默认版本的
  • PowerShell 和 StringBuilder

    我是 PowerShell 新手 但熟悉 NET 类 我在用System Text StringBuilder在 PowerShell 脚本中 脚本是这样的 Function MyStringFunc String line r New O
  • 将 Metro 应用程序固定到任务栏 Windows 10 Powershell

    以下代码将固定 Metro 应用程序以在给定 AUMID 的情况下启动 如果你改变 match Pin To Start 不幸的是 将匹配更改为 固定到任务栏 不起作用 这里发生了什么 function Pin Taskbar param
  • 如何在 PowerShell 中比较本地文件与 FTP 服务器上的文件的年龄并下载远程复制是否较新

    我正在编写一个 PowerShell 脚本 以帮助我为工作设置新电脑 希望这不仅仅是我一个人会使用 所以我正在尝试考虑所有事情 我在 FTP 服务器上保存了离线安装程序 java flash reader 等 如果本地副本尚未保存在创建的
  • FileInfo.BaseName 存在于 PowerShell 中,但不存在于直接 .NET 中

    为什么在 NET 中System IO FileInfo对象没有BaseName属性 但我可以通过 PowerShell 使用该属性 例如 FolderItems Get ChildItem Path C Where Object isno
  • Powershell tail 多个文件命令

    我可以通过以下命令尾随一个文件 Get Content Path C log1 txt Tail 10 Wait 如何将其扩展到多个文件 我尝试了以下方法但没有成功 Get Content Path C log1 txt C log2 tx
  • 在 selenium webdriver 中打开一个新窗口而不是新选项卡

    当在我的应用程序中手动单击链接时 它会在 Chrome 和 IE 中的新选项卡中打开 但是 当我的脚本运行时 该链接会在 IE 中的新窗口而不是新选项卡中打开 相同的脚本在 Chrome 中按预期运行 知道如何摆脱这个吗 更改 IE 的默认
  • Javascript/jQuery 外部高度()

    Does idOfLememt outerHeight 对所有浏览器产生相同的结果 IE7 有什么不同吗 只要去http api jquery com outerHeight http api jquery com outerHeight
  • 我的 Powershell GUI 界面在打开网格视图时不断调整大小

    我目前正在构建一个复制到剪贴板工具 其中显示存储在文件夹中的 txt 文件列表 并且我使用 out gridview 来允许用户更好地选择和过滤列表 我已附上图片以供参考 单击加载 out gridview 的按钮后如何停止调整大小 Too
  • 填充 datagridview

    我正在开发一个表单 它将在所有连接的驱动器中搜索 PST 文件 我可以使用以下命令让它工作 Get PSDrive PSProvider filesystem get childitem root include pst r select
  • [Regex]::Replace() 和 -replace 有什么区别?

    我明白了之间的区别 Replace and replace 但是什么是 replace and Regex Replace 我测试了以下两个代码 但对我来说结果完全相同 我还提到了 PowerShell Cookbook O reilly
  • 使用 UTF-8 编码的 Powershell 字符串变量

    我检查了许多与此相关的问题 但找不到解决我的问题的东西 基本上 我想将 UTF 8 编码的字符串存储在变量中 然后使用该字符串作为文件名 例如 我正在尝试下载 YouTube 视频 如果我们打印视频标题 则会显示非英文字符 ytd这是you
  • 如何从 Internet Explorer 获取与 cookie 关联的过期日期和标志?

    我可以得到 cookie 的值互联网获取Cookie http msdn microsoft com en us library windows desktop aa384710 28v vs 85 29 aspx or InternetG
  • 如何在管道函数中使用 Write-Progress?

    我正在尝试编写一个函数PowerShell接受管道输入 我想使用显示进度条Write Progress 管道中每个项目的增量 例如 function Write PipelineProgress Cmdletbinding Param Pa
  • Pester 没有捕获抛出的错误

    当我运行以下纠缠测试时 我希望它能够捕获预期的错误 但事实并非如此 但是 当我使用不同的函数和不同的 throw 语句运行测试时 它会起作用 纠缠测试 Describe Remove GenericCredential Function T

随机推荐