When I open any video with powershell it turns out the recommended videos on the right side.
I tried to solve the problem in two ways.But neither of them gives the results I want.
way 1
$URI = 'https://www.youtube.com/watch?v=lpeuIu-ZYJY'
$HTML=Invoke-WebRequest -Uri $URI
$HTML.ParsedHtml.getElementsByTagName('ytd-compact-video-renderer') | Where{ $_.className-eq 'style-scope ytd-watch-next-secondary-results-renderer' } | ForEach-Object { $_.getElementsByTagName('a') } | Select-Object -Expand href
way 2
$URI = 'https://www.youtube.com/watch?v=lpeuIu-ZYJY'
$HTML=Invoke-WebRequest -Uri $URI
$HTML.Links | Where href -like '/watch*' | select outertext,href
how do i download recommended videos on the right? Sample video: https://www.youtube.com/watch?v=lrYlcytsBdE
Can you help me solve my problem?
You can get the list of recommended video's like this:
$URI = 'https://www.youtube.com/watch?v=lpeuIu-ZYJY'
$HTML = Invoke-WebRequest -Uri $URI
$HTML.Links | Where-Object { $_.href -like '/watch*' -and (!(!$_.title)) } | fl title,href
As for downloading, you could try using youtube-dl