Skip to content

Instantly share code, notes, and snippets.

@saverdaj
Created February 9, 2012 02:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saverdaj/1776512 to your computer and use it in GitHub Desktop.
Save saverdaj/1776512 to your computer and use it in GitHub Desktop.
<?php
include("simple_html_dom.php");
// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');
// Find all images
/*foreach($html->find('img') as $element)
echo $element->src . '<br>';
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
*/
error_reporting(E_ERROR | E_PARSE);
$dom = new DOMDocument();
$dom->loadHTMLFile('http://www.xbox360achievements.org/games/retail/');
$xml = simplexml_import_dom($dom);
$links = $xml->xpath('//table/tr/td/a');
for($i=30;$i<count($links);$i++):
?>
<a target="_blank" href="http://www.xbox360achievements.org/games/retail/<?php echo $links[$i]['href']; ?>"><?php echo $links[$i]['href']; ?></a><br/>
<?php
endfor;
echo "Hi";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment