浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
System.properties.putAll( ["http.proxyHost":"10.10.224.97", "http.proxyPort":"80","http.proxyUserName":"admin", "http.proxyPassword":"admin888"] )

def url="http://detail.tmall.com/item.htm?id=8039043384&"
url="http://www.baidu.com"
html=url.toURL().text
//def matcher=( html=~ /<strong id="J_StrPrice"/ )
//println matcher


println html

String ResultString = null;
try {
    Pattern regex = Pattern.compile("<strong id=\"J_StrPrice\" >([\\s\\S]*?)</strong>");
    Matcher regexMatcher = regex.matcher(html);
    if (regexMatcher.find()) {
        ResultString = regexMatcher.group(1);
        println(ResultString)
    }
    else
    {
        println("zzzz")
    }
} catch (PatternSyntaxException ex) {
    // Syntax error in the regular expression
}

posted on 2012-06-28 15:46  lexus  阅读(284)  评论(0)    收藏  举报