Internet Explorer 엔진을 사용할 수 없기 때문에 응답 콘텐츠를 구문 분석 할 수 없습니다.
powershell을 사용하여 채널 9 시리즈를 다운로드해야하지만 시도한 스크립트에 오류가 있습니다.
이 스크립트
$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 매개 변수를 지정하고 다시 시도하십시오.
나는 또한 이것을 시도했다
# --- 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
너무 많은 오류
웹 요청 호출에서 매개 변수를 사용하십시오. -UseBasicParsing
예를 들어 스크립트 (라인 2)에서 다음을 사용해야합니다.
$rss = Invoke-WebRequest -Uri $url -UseBasicParsing
스크립트를 수정하지 않고 작동하게하려면 :
여기에서 해결책을 찾았습니다. http://wahlnetwork.com/2015/11/17/solving-the-first-launch-configuration-error-with-powershells-invoke-webrequest-cmdlet/
The error is probably coming up because IE has not yet been launched for the first time, bringing up the window below. Launch it and get through that screen, and then the error message will not come up any more. No need to modify any scripts.
It is sure because the Invoke-WebRequest command has a dependency on the Internet Explorer assemblies and are invoking it to parse the result as per default behaviour. As Matt suggest, you can simply launch IE and make your selection in the settings prompt which is popping up at first launch. And the error you experience will disappear.
But this is only possible if you run your powershell scripts as the same windows user as whom you launched the IE with. The IE settings are stored under your current windows profile. So if you, like me run your task in a scheduler on a server as the SYSTEM user, this will not work.
So here you will have to change your scripts and add the -UseBasicParsing argument, as ijn this example: $WebResponse = Invoke-WebRequest -Uri $url -TimeoutSec 1800 -ErrorAction:Stop -Method:Post -Headers $headers -UseBasicParsing
'programing' 카테고리의 다른 글
Google 검색 "이것을 의미 했습니까"알고리즘에 대한 자세한 내용은 어디에서 확인할 수 있습니까? (0) | 2020.11.03 |
---|---|
JavaScript / jQuery를 사용하여 ASP.NET MVC의 다른 페이지로 리디렉션 (0) | 2020.11.03 |
C ++ 템플릿 매개 변수를 하위 클래스로 제한 (0) | 2020.11.03 |
gradle (1.1.2-5)로 빌드하는 데 사용되는 kotlin 버전이 IDE 플러그인 (1.1.2-4)에 번들로 제공되는 버전과 다릅니다. (0) | 2020.11.03 |
조인 및 행 기반 제한 (페이징)을 사용하여 최대 절전 모드에서 고유 한 결과를 얻는 방법은 무엇입니까? (0) | 2020.11.03 |