I have the following script which includes some RegEx to capture specific information on this site.
$Top40Response = Invoke-WebRequest -UseBasicParsing -Uri 'https://www.radioinfo.com.au/knowledge/chart'
$Top40Response.Content -match '<td\Wclass="twRank">[\s\S]+artist">([^<]*)'
$matches
This is matching the last 'artist'. What I want to do is make this so it will run through and match every artist on this page in order top to bottom.
PowerShell's -match
only returns first match. You have to use Select-String
with -AllMatches
parameter or [regex]::Matches
.
Select-String
:
$Top40Response = Invoke-WebRequest -UseBasicParsing -Uri 'https://www.radioinfo.com.au/knowledge/chart'
$Top40Response.Content |
Select-String -Pattern '<td\s+class="artist">(.*?)<\/td>' -AllMatches |
ForEach-Object {$_.Matches} |
ForEach-Object {$_.Groups[1].Value}
[regex]::Matches
:
$Top40Response = Invoke-WebRequest -UseBasicParsing -Uri 'https://www.radioinfo.com.au/knowledge/chart'
$Top40Response.Content |
ForEach-Object {[regex]::Matches($_, '<td\s+class="artist">(.*?)<\/td>')} |
ForEach-Object {$_.Groups[1].value}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With