Public/Get-TomGauld.ps1
function Get-TomGauld { param ( ) $AmericanCulture = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'en-US' Invoke-WebRequest -Uri 'https://www.newscientist.com/author/tom-gauld/' | Select-Object -ExpandProperty Links | Where-Object href -Like '/article/*' | ForEach-Object { $Url = "https://www.newscientist.com$($_.href)"; $Url } | ForEach-Object { Invoke-WebRequest -Uri $_ } | Select-Object -ExpandProperty Content | ForEach-Object { $DateText = (($_ | pup '.published-date text{}' --plain) -join '' -replace '[\r\n]', '').Trim() $Date = [DateTime]::ParseExact($DateText, 'd MMMM yyyy', $AmericanCulture) $Title = (($_ | pup 'h1 text{}' --plain) -join '' -replace '[\r\n]', '').Trim() $Image = ($_ | pup 'figure.article-image-inline img attr{data-src}') -replace '300$', '600' [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.NewScientist.Article' Url = $Url Date = $Date Title = $Title Body = $Image } } } |