Revision: 12051
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 28, 2009 18:59 by Unreal
Initial Code
$html = file_get_contents('http://www.example.com');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
Initial URL
http://www.imben.co.uk
Initial Description
The basis to a spider.
Initial Title
Find All The Links On A Page
Initial Tags
page, DOM, links, find
Initial Language
PHP