All pastes #894662 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-07 03:56 UTC
rendered paste body
<?php

$dom = new DOMDocument();
@$dom->loadHTML(file_get_contents('http://www.google.com'));

$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//h2/a");

for($i = 0; $i < $hrefs->length; $i++) {
  $href = $hrefs->item($i);
  $url = $href->getAttribute('href');
  echo $url . "\n";
}