Created
September 10, 2015 16:54
-
-
Save veb/aea6ef22fda992370245 to your computer and use it in GitHub Desktop.
articles-4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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