我curl_exec 和curl_init 我想对初始化的curl session 的源代码进行一些更改。(在PHP、JAVASCRIPT或任何其他中) 有人知道吗? 请帮忙
最佳答案
试试这个代码:
$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);
这将返回 html 代码,之后您可以使用另一个函数来更改它,例如:str_replace
或 preg_replace
关于php - 调用curl_init后如何更改HTML源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8936870/