Page 1 of 1

Replace HTML code of a webpage with PHP

Posted: Tue Dec 16, 2008 12:10 pm
by arjunetal
Hello everyone!!!
well I just want to know how can I replace the html code of a given webpage.
Like I want to change the code of a webpage whos address is http://www.xyz.com/abc.html
now i would like to change some code in it, to a different one....
can you give me the script for that {suppose the script is change.php
i would like to use it like this http://www.mysite.com/change.php?www.xyz.com/abc.html

i want outpur same as of http://www.xyz.com/abc.html, but with specific changes that i have coded in change.php

Thanks in Advance
Arjun Gupta
arjunetal@gmail.com

Re: Replace HTML code of a webpage with PHP

Posted: Tue Dec 16, 2008 12:32 pm
by John Cartwright
Thats a very broad question. What have you tried so far?

Lets start simple. The first step is fetching the page contents, and I would recommend using cURL for this.

Code: Select all

 
$url = 'http://some_page_you_want_to_visit.com';
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //retrive output and do not display it
$content = curl_exec($ch);