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.
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.
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: