You’re about to finish work and you don’t know what to watch tonight. The International Movies Database and the Powershell script printed here will help you with your decision:
# https://www.imdb.com/chart/top?ref_=nv_mv_250 - Top Rated Movies
# https://www.imdb.com/chart/toptv/?ref_=nv_tvv_250 - Top Rated TV Shows
$outfile = "C:\temp\movies.json";
$website = Invoke-WebRequest https://www.imdb.com/chart/top?ref_=nv_mv_250
$rows = $website.ParsedHtml.body.getElementsByClassName("titleColumn") | select InnerText
$AllMovies = @{Movies = @()};
$rows.InnerText | select-string -Pattern ("^(\d*)([.])(.*)(\()(\d\d\d\d)") -AllMatches | % {
$AllMovies.Movies += @{
Rank = $("{0:000}" -f [Int32]$_.Matches.Groups[1].Value)
Title = $_.Matches.Groups[3].Value.Trim()
Release = $_.Matches.Groups[5].Value
}
# Write-Host is just for debugging
Write-Host $("{0:000}" -f [Int32]$_.Matches.Groups[1].Value) : $_.Matches.Groups[3].Value.Trim() : $_.Matches.Groups[5].Value;
}
ConvertTo-Json $AllMovies | Out-File $outfile -Force;Have fun!