I'm trying to make a little fun page like something I already saw on internet some years ago. What I want to do is to take all the content of a distant web page, change some words (for example, replace random words by "blablabla") and show it on my server (of course it's impossible to change content on the distant server). It must have the same css look etc, as if it was an iframe, with just some words replaced.
I succeeded in grabbing distant content (with curl) and show it with DOMDocument
$url = "http://www.example.fr";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($curl);
curl_close($curl);
$DOM = new DOMDocument;
$DOM->loadHTML($output);
echo $DOM->saveHTML();
But now I want to edit all viewable text on the page (titles, content, etc) to change some random words. I can make it on a particular website by changing Id's content with :
$DOM->getElementsByTagName('h1');
But not every websites have h1 or h2 etc. I just want to change the text displayed no matter id it is. I don't know if DOMDocument has a function for this. Thank you !