/ Published in: Windows PowerShell
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
param ($path, $urlpath) add-type -Path f:\dan\tools\html-agility-pack\HtmlAgilityPack.dll $files = Get-ChildItem -Include *.htm,*.aspx -Path $path -Recurse $doc = New-Object HtmlAgilityPack.HtmlDocument $result = $files | % { Write-Host "Checking $_" $linknodes = $doc.DocumentNode.SelectNodes("//a") if ($linknodes) { foreach ($node in $linknodes) { if ($node.GetAttributeValue("href", "").ToLower().Contains("pdf")) { Write-Host "Found" $node.GetAttributeValue("href", "") $pdflink = $node.GetAttributeValue("href", "") $line = $node.Line New-Object PsObject -Property @{PdfLink = $pdflink; FileName = $name; LineNumber = $line;} } } } } $result | Sort PdfLink