【问题标题】:Removing html tags in cURL删除 cURL 中的 html 标签
【发布时间】:2017-07-08 22:31:55
【问题描述】:

我正在尝试以纯文本形式获取 url 的内容。目前我已经设法从 url 获取所有 HTML 内容。我想知道是否可以删除 cURL 中的 html 标签。

 <?php
    // put your code here
    $ch = curl_init();
    $url = "http://visitbirmingham.com/explore-birmingham/blog";
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    $cResult = curl_exec($ch);
    curl_close($ch);

    $cResult = str_replace("<", "&lt;", $cResult);
    $cResult = str_replace(">", "&gt;", $cResult);

    echo  $cResult;

    ?>

【问题讨论】:

  • 哇,google php remove html tags 太棒了。

标签: php html curl


【解决方案1】:

查看 php 函数 strip_tags

echo strip_tags($cResult);

【讨论】:

    猜你喜欢
    • 2013-02-18
    • 2018-02-10
    • 1970-01-01
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-25
    相关资源
    最近更新 更多