Last active
April 29, 2016 06:42
-
-
Save tingplenting/e6bb16df91630658af2482be162719fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require '../simple_html_dom.php'; | |
function grab_html($url) | |
{ | |
$file = file_get_contents($url); | |
return $file; | |
} | |
// http://php.net/manual/en/book.dom.php#89718 | |
function domInnerHtml($element) | |
{ | |
$innerHTML = ""; | |
$children = $element->childNodes; | |
foreach ($children as $child) | |
{ | |
$tmp_dom = new DOMDocument(); | |
$tmp_dom->appendChild($tmp_dom->importNode($child, true)); | |
$innerHTML .= trim($tmp_dom->saveHTML()); | |
} | |
return $innerHTML; | |
} | |
$html_page = grab_html($url); | |
$to_code = str_replace('<div>','<code>',$html_page); | |
$to_code = str_replace('</div>','</code>',$to_code); | |
$dom_code = new domDocument(); | |
@$dom_code->loadHTML($to_code); | |
$get_code_tag = $dom_code->getElementsByTagName('code'); | |
$coded_page = ''; | |
foreach ($get_code_tag as $coded_tag) | |
{ | |
$coded_page .= DOMinnerHTML($coded_tag); | |
} | |
file_put_contents('noindex.html', $coded_page); | |
$html = file_get_html('noindex.html'); | |
echo $html; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment