Head
Head

Reputation: 568

Using the php method file_get_contents I'm pulling an entire webpage to my website

Here's my code:

<?php 
$html = file_get_contents("http://aaaaaa.bbbbb.com/thisstuff");

$dom = new DOMDocument;
$dom->loadHTML($html);

var_dump ($dom->getElementsByTagName('div'));

  for ($i = 0; $i < $items->length; $i++)
         echo $items->item($i)->nodeValue . "<br/>";
?>

The only div class on the page i need to retrieve is:

class="fap index" id="canvas"

How should i got about this, perhaps using document.getElementById?

Any help would be greatly appreciated. Thank you.

Upvotes: 0

Views: 126

Answers (1)

Mike Brant
Mike Brant

Reputation: 71384

Yes, you can use:

$canvas = $dom->getElementById('canvas');

Not sure what you want to do with the DOMElement object that would be set to $canvas, but you can obviously look at the documentation for DOMElement to see the available methods on it.

http://php.net/manual/en/class.domelement.php

Upvotes: 1

Related Questions