/ Published in: Windows PowerShell
Expand |
Embed | Plain Text
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 $_" $name = $_\3.FullName.Replace($path,$urlpath).Replace("\", "/") $htmldoc = $doc.Load($_\3.FullName) $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
You need to login to post a comment.
