【问题标题】:Identify if html contains template language code while extracting from URL从 URL 中提取时识别 html 是否包含模板语言代码
【发布时间】:2016-03-03 00:36:36
【问题描述】:

我正在尝试从任何提供的包含一些文本数据的 URL 中获取纯文本内容。在其中一个 URL 上测试该功能时,我发现源代码中存在一些模板语言代码。

{{if user.username || user.id}}
                {{:user.name}}

知道如何从我的输出 html 中清除此代码吗?是否有可能使用 PHP 实现这样的目标?

【问题讨论】:

    标签: php html-content-extraction


    【解决方案1】:

    你可以这样使用:

    $filtered_string = preg_replace('/' . preg_quote('{{') .
        '.*?' .
        preg_quote('}}') . '/', '', $str);
    

    这里$str 将是您输入的html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      • 1970-01-01
      • 1970-01-01
      • 2012-01-06
      • 1970-01-01
      相关资源
      最近更新 更多