php - 调用curl_init后如何更改HTML源代码?

标签 php javascript html curl

我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_replacepreg_replace

关于php - 调用curl_init后如何更改HTML源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8936870/

相关文章:

php - 删除/过滤数组元素中的字符和/或单词

javascript - 将 Yii 中的下拉列表更改为文本框

PHP setlocale(LC_MONETARY, 'en_US') 没有按预期工作

php - HTML 表单 - 不会使用 PHP 更新 Mysql 数据库

javascript - 序列化 hasMany 为 "Where"

html - 圆形复选框边框不会改变

html - 浏览器如何计算 DIV 高度?

Jquery 检查 div 是否为空,省略 : before or: after

phpMyadmin 无法导入文件,错误为 : open_basedir > enabled without access to the/tmp directory

javascript - 如何使用 node-postgres 将多行正确插入 PG?