Skip to content

Instantly share code, notes, and snippets.

@veb
Created September 10, 2015 16:52
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/0e445698969ded0c6ae7 to your computer and use it in GitHub Desktop.
Save veb/0e445698969ded0c6ae7 to your computer and use it in GitHub Desktop.
articles-2
<?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