Created
September 10, 2015 16:52
-
-
Save veb/0e445698969ded0c6ae7 to your computer and use it in GitHub Desktop.
articles-2
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); | |
$rightDivText = $xpath->query("//html/body/div[@id='mainDiv']/div[@id='rightDiv']/p/text()"); | |
// Returns: This is right | |
echo $rightDivText->item(0)->nodeValue; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment