zoukankan      html  css  js  c++  java
  • 去除所有js,html,css代码问题

    1 $search = array ("'<script[^>]*?>.*?</script>'si", // 去掉 javascript
    2   "'<style[^>]*?>.*?</style>'si", // 去掉 css
    3 "'<[/!]*?[^<>]*?>'si", // 去掉 HTML 标记
    4 "'<!--[/!]*?[^<>]*?>'si", // 去掉 注释标记
    5 "'([rn])[s]+'", // 去掉空白字符
    6 "'&(quot|#34);'i", // 替换 HTML 实体
    7 "'&(amp|#38);'i",
    8 "'&(lt|#60);'i",
    9 "'&(gt|#62);'i",
    10 "'&(nbsp|#160);'i",
    11 "'&(iexcl|#161);'i",
    12 "'&(cent|#162);'i",
    13 "'&(pound|#163);'i",
    14 "'&(copy|#169);'i",
    15 "'&#(d+);'e"); // 作为 PHP 代码运行
    16
    17 $replace = array ("",
    18 "",
    19 "",
    20 "",
    21 "\1",
    22 "\"",
    23 "&",
    24 "<",
    25 ">",
    26 " ",
    27 chr(161),
    28 chr(162),
    29 chr(163),
    30 chr(169),
    31 "chr(\1)");
    32 //$document为需要处理字符串,如果来源为文件可以$document = file_get_contents('http://www.sina.com.cn');
    33 $document = file_get_contents('http://www.sina.com.cn');
    34 $out = preg_replace($search, $replace, $document);
    35 echo $out;

    aliyun活动 https://www.aliyun.com/acts/limit-buy?userCode=re2o7acl
  • 相关阅读:
    RMQ
    LCA 笔记
    LUCAS 定理
    topcoder 643 DIV2
    BZOJ 1071组队
    Codeforces Round #283 (Div. 2)
    topcoder 642
    Codeforces Round #278 (Div. 2)
    树链剖分
    Codeforces Round #277 (Div. 2)
  • 原文地址:https://www.cnblogs.com/wangbin/p/1763372.html
Copyright © 2011-2022 走看看