Jump to content

Searching HTML results of file_get_contents()


pitbullent

Recommended Posts

Hi!

  I'm SO CONFUSED. OK all I want to do is use PHP to access a specific website and display only the content of a specific DIV on that website.  The class of the div is "content_box".

 

<div class="content_box">

 

My thoughts lead me to think that I can use

 

$results = file_get_contents('website');

 

to put all of the HTML into a variable and then use one of the preg functions to extract the div and display it.

 

preg_match('<div class=\"content_box\"> *allow anything including nested divs* </div>', $results, $div);
print $div;

 

This is where my ideas fall apart. I have absolutely no idea on how to get started on the regex for a specific div much less allowing for nested divs.

 

Is this the wrong approach altogether? Thank you so much in advance for any ideas or code you can supply!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.