0

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
  • to what purpose? taking HTML from a CURL session to then be output to the browser? details? Commented Jan 20, 2012 at 5:20

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.