I curl_exec a curl_init I want to make some alterations in the source code of the initialised curl session.(in PHP,JAVASCRIPT or ANYthing else) Anybody got any idea? Please help
1 Answer
Try this code out:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://stackoverflow.com/questions/8936870/how-to-change-the-html-source-code-after-calling-a-curl-init");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($curl); // run CURL
curl_close($curl);
echo $html; // and finally, return $html
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
This will return the html code, and after that you can use another function to change this like: str_replace or preg_replace