zoukankan      html  css  js  c++  java
  • 截取html中的某个节点

    String content = "<meta property="og:description" content="freeCodeCamp Earth &#x6709; 127,712 &#x4f4d;&#x6210;&#x54e1;&#x3002; Welcome to freeCodeCamp Earth!
    " +
                    "
    " +
                    "This is a relaxing place to discuss coding and share your accomplishments.
    " +
                    "
    " +
                    "To keep this Facebook group civil, our moderator team..." />
    " +
                    "	<meta property="og:url" content="https://www.facebook.com/groups/321090721625587/" />
    " +
                    "	<meta property="og:locale" content="en_US" />";
            String readText = "";
    //        Pattern p = Pattern.compile("<div\s*class=["']mail-trace["'](.*)>(.*)<\/div>");
            Pattern p = Pattern.compile("<meta\s*property=["']og:url["'](.*)(.*)\/>");
            Matcher matcher = p.matcher(content);
            if (matcher.find()) {
                for (int i = 0; i <= matcher.groupCount() && StringUtils.isEmpty(readText); i++) {
                    readText += matcher.group(i);
                }
            }
            System.out.println(readText);
    <meta property="og:description" content="freeCodeCamp Earth &#x6709; 127,712 &#x4f4d;&#x6210;&#x54e1;&#x3002; Welcome to freeCodeCamp Earth!
    
    This is a relaxing place to discuss coding and share your accomplishments.
    
    To keep this Facebook group civil, our moderator team..." />
        <meta property="og:url" content="https://www.facebook.com/groups/321090721625587/" />     要匹配内容!
        <meta property="og:locale" content="en_US" />
  • 相关阅读:
    使用jsonp跨域调用百度js实现搜索框智能提示(转)
    jsonp 跨域
    Aixs2发布webservice服务
    java web service 上传下载文件
    java 网页 保存上传文件
    flash、js 函数 互相调用
    java web工程启动socket服务
    mysql 在Windows下自动备份
    Servlet中几个常用方法的推衍
    Tomcat常用设置 <持续更新>
  • 原文地址:https://www.cnblogs.com/wanhua-wu/p/13638366.html
Copyright © 2011-2022 走看看