Skip to content

Instantly share code, notes, and snippets.

@veb
Created September 10, 2015 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veb/aea6ef22fda992370245 to your computer and use it in GitHub Desktop.
Save veb/aea6ef22fda992370245 to your computer and use it in GitHub Desktop.
articles-4
<?php
// $content is the content you scraped (via curl for example)
$dom = new DOMDocument();
@$dom->loadHTML($content)
$xpath = new DOMXPath($dom);
$imgSrc = $xpath->query("//html/body/div[1]/div[1]/img/@src");
// Returns: images/test.jpg
echo $imgSrc->item(0)->nodeValue;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment