0

I want to get inner HTML of a website using PHP, is it possible?

I only know about file_get_contents($URL) method for getting the source.

Tom Walters
  • 15,366
  • 7
  • 57
  • 74

2 Answers2

0

You can use curl for send HTTP headers and anothe socket params.

0

You can use Simple HTML Dom to traverse and parse well-formed HTML:

http://sourceforge.net/projects/simplehtmldom/

For example:

<?php

include_once('simple_html_dom.php');
$html = file_get_html('http://target.page.com');

// Output the contents of <div id="target-id">
$content = $html->find('div#target-id');
echo $content[0]->plaintext;

// Output the entire page as plaintext
echo $html->plaintext;

?>

Documentation can be found here:

http://simplehtmldom.sourceforge.net/manual.htm

lwitzel
  • 591
  • 5
  • 15