php url crawler

Crawl a webpage for all url Method – 1 <?php function crawl_page($url, $depth = 5) { $arr = array(); static $seen = array(); if (isset($seen[$url]) || $depth === 0) { return; } $seen[$url] = true; $dom = new DOMDocument(‘1.0’); @$dom->loadHTMLFile($url); $anchors = $dom->getElementsByTagName(‘a’); foreach ($anchors as $element) { $href = $element->getAttribute(‘href’); if (0 !== strpos($href, […]

Read More