gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 05:19:59 30 4
gpt4 key购买 nike

我需要使用 powershell 下载 channel 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
    }
    }

    失败并出现错误:

    The response content cannot be parsed because the Internet Explorer engine is not available, or Internet Explorer's first-launch configuration is not complete. Specify the UseBasicParsing parameter and try again.

  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

最佳答案

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

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

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

根据the documentation ,在未安装或配置 IE 的系统上此参数是必需的:

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 - 由于 Internet Explorer 引擎不可用,无法解析响应内容,或者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38005341/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com