Public/Get-LawOfSoftware.ps1
function Get-LawOfSoftware { param ( ) Invoke-WebRequest -Uri 'https://www.laws-of-software.com' | Select-Object -ExpandProperty Links | Select-Object -ExpandProperty HRef | Where-Object { $_ -like 'https://www.laws-of-software.com/?laws/*' } | ForEach-Object { $Document = ConvertTo-HtmlDocument -Uri $_ $Title = $Document | Select-HtmlNode -CssSelector 'h1' | Get-HtmlNodeText $Paragraphs = $Document | Select-HtmlNode -CssSelector 'blockquote p' -All $Explanation = $Document | Select-HtmlNode -CssSelector '.wrap-content > p' -All | Get-HtmlNodeText $Law = $Paragraphs | Select-Object -SkipLast 1 | Get-HtmlNodeText $Author = $Paragraphs | Select-Object -Last 1 | Get-HtmlNodeText $Author = $Author -replace '^--\s', '' $Author, $Year = $Author -split ', ' [PSCustomObject]@{ PSTypeName = 'UncommonSense.LawsOfSoftware.Law' Title = $Title Law = $Law Author = $Author Year = $Year Explanation = $Explanation } } } |