/ Published in: Windows PowerShell

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
param ($url, $tofind, $agilitypackpath="f:\dan\tools\html-agility-pack\HtmlAgilityPack.dll", $xpath="//a") add-type -Path $agilitypackpath $client = New-Object System.Net.WebClient $contents = $client.DownloadString($url) $doc = New-Object HtmlAgilityPack.HtmlDocument $htmldoc = $doc.LoadHtml($contents) $linknodes = $doc.DocumentNode.SelectNodes($xpath) foreach ($node in $linknodes) { $link = $node.GetAttributeValue("href", "") if ($link) { $c = $client.DownloadString($link) if ($c.Contains($tofind)) { $isfound = "true"; } else { $isfound = "false"; } New-Object PsObject -Property @{Url = $link; IsFound = $isfound;} } }
Comments
