php - Change content of distant web page -
i'm trying make little fun page saw on internet years ago. want take content of distant web page, change words (for example, replace random words "blablabla") , show on server (of course it's impossible change content on distant server). must have same css etc, if iframe, words replaced.
i succeeded in grabbing distant content (with curl) , show 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 want edit viewable text on page (titles, content, etc) change random words. can make on particular website changing id's content :
$dom->getelementsbytagname('h1');
but not every websites have h1 or h2 etc. want change text displayed no matter id is. don't know if domdocument has function this. thank !
Comments
Post a Comment