So I am just trying to scrape an HTML page with PHP. I looked on Google for how to do it, and I uuse the file_get_contents() method. I wrote a little bit of code, but I am already getting an error that I cannot figure out:
$page = file_get_contents( 'http://php.net/supported-versions.php' );
$doc = new DOMDocument( $page );
//print_r( $page );
foreach ( $doc->getElementsByTagName( 'table' ) as $node ) {
print_r( $node );
}
The first, commented out print_r statement DOES print the page, but the foreach loop should be getting every table in $node but it is printing nothing. What am I doing wrong?
DOMDocumentparser? It is able to do this, he just made a little mistake.