Skip to content

Instantly share code, notes, and snippets.

@jhaus
Created January 24, 2011 10:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhaus/793038 to your computer and use it in GitHub Desktop.
Save jhaus/793038 to your computer and use it in GitHub Desktop.
<?php
$url = "http://icanhascheezburger.com";
$html = file_get_contents($url);
$dom = new DomDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$img = $xpath->evaluate("//div[@class='entry']//img")->item(0);
$imgSrc = $img->getAttribute('src');
print("<img src=\"$imgSrc\" />");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment