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 { ConvertTo-HtmlDocument -Uri $_ } | ForEach-Object { $DateText = $_ | Select-HtmlNode -CssSelector '.ArticleHeader__Date' | Get-HtmlNodeText $Date = [DateTime]::ParseExact($DateText, 'd MMMM yyyy', $AmericanCulture) $Title = $_ | Select-HtmlNode -CssSelector 'h1' | Get-HtmlNodeText $Image = ($_ | Select-HtmlNode -CssSelector 'figure.article-image-inline img').GetAttributeValue('data-src', '') $Image = $Image -replace '300$', '900' [PSCustomObject][Ordered]@{ PSTypeName = 'UncommonSense.NewScientist.Article' Url = $Url Date = $Date Title = $Title Body = $Image } } } |