IBMSOFT

ibmsoft 努力不一定成功,放弃一定失败! 坚持自己的理想,实现自己的目标! 有好的想法就要出想办法实现!

BlogJava 首页 新随笔 联系 聚合 管理
  8 Posts :: 2 Stories :: 3 Comments :: 0 Trackbacks
  • I use nutch to crawl the intranet.but you know ,the cache.jsp have mang problem (X).Because I filter the gif|jgf and so on
    then I use ORO replace the html content use my customer pif
    Code:
     1    String sRegexpSrc="src\\s*=\\s*\"([\\.]*)/([a-z]*)/([^\"]+)";
     2    String sRegxpBackground ="background\\s*=\\s*\"([.]*)/([a-z]*)/([^\"]+)";
     3    String sAdd = "";
     4    String sNewContent="";
     5    PatternCompiler compiler = new Perl5Compiler();
     6    Pattern pattern = null,pattern1 = null ;
     7    try{
     8        pattern = compiler.compile(sRegexpSrc,Perl5Compiler.CASE_INSENSITIVE_MASK);
     9        pattern1 = compiler.compile(sRegxpBackground,Perl5Compiler.CASE_INSENSITIVE_MASK);
    10    }
    catch (MalformedPatternException e){
    11        
    12        e.printStackTrace();
    13    }

    14    PatternMatcher matcher = new Perl5Matcher();
    15
    16if (matcher.contains(content, pattern)){
    17                    MatchResult result = matcher.getMatch();
    18                    //System.out.println(result.toString());
    19                    sAdd = result.group(1)+"/"+result.group(2)+"/"+result.group(3);
    20                    //System.out.println("sAdd= "+sAdd);
    21                    sNewContent=content.replaceAll(sAdd,"\\img\\liuxuan");
    22                    //System.out.println("FinalString="+sTest.replaceAll(sAdd,"/img/liuxuan.png"));
    23            //System.out.print("sTest= "+result.group(1)+"/"+result.group(2));
    24        }
    else{
    25            //System.out.print("Can't find the String ");
    26
    27        }

posted on 2006-06-28 21:03 ibmsoft 阅读(329) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: