I working on scrapping microsoft website where i want to fetch sql product name such as "SQL Version 2012" using their version "11.0.6607.3".
Basically I want to search for their product name using their Version. Help me with powershell using invoke-webrequest.
Thanks in Advance
This is what I have tried
$url = "https://learn.microsoft.com/en-us/troubleshoot/sql/releases/download-and-install-latest-updates"
$html.content = Invoke-WebRequest -Uri $url
# Find the table rows (tr) in the HTML
$rows = ($html.content).ParsedHtml.getElementsByTagName('tr')
# Define the version number to search for
$searchVersion = '11.0.5058.0'
# Loop through the rows and find the matching version number
foreach ($row in $rows) {
$cells = $row.getElementsByTagName('td')
if ($cells.Count -gt 1 -and $cells[1].innerText -match $searchVersion) {
# The version number is found in the second cell of the row
# Output the SQL Server version from the first cell of the same row
Write-Output $cells[0].innerText
break # Exit the loop after the first match is found
}
}