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

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

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

import java.util.regex.*
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" >([\s\S]*?)<\/strong>/ )
if (matcher.find())
{
    def temp_price= matcher[0][1]
    if(temp_price.isNumber())
    {
       //println Double.parseDouble(temp_price)
       temp_price=temp_price as double
       println temp_price.toString()
    }
}
else
{
    println "未匹配"
}

posted on 2012-06-28 17:47  lexus  阅读(334)  评论(0编辑  收藏  举报