- file_get_contents: documentation ( source)
- var_dump: documentation ( source)
- header: documentation ( source)
- libxml_use_internal_errors: documentation ( source)
<?php
// vim: ts=3 sw=3 sts=3 et
$body = file_get_contents('http://www.google.com');
libxml_use_internal_errors(true);
$dom = new DOMDocument;
$dom->loadHTML($body);
$xpath = new DOMXPath($dom);
$found = $xpath->query(
'//a[
not(starts-with(normalize-space(@href), "http://")) and
not(starts-with(normalize-space(@href), "https://"))
]');
header('content-type: text/plain');
foreach ($found as $node)
{
var_dump($node->getAttribute('href'));
}