页面:http://item.taobao.com/item.htm?id=7257454883
提取页面title:
<div class="tb-gallery">下img图片地址:
<strong id="J_StrPrice" >29.99</strong>下价格:29.99
求用正则怎么获取?

解决方案 »

  1.   


            ep:
            string pstr ="(is)<title>(?<Title>.*?)</title>.*?<strong id=\"J_StrPrice\" >(?<Price>.*?)</strong>";
            Match m = Regex.Match(input, pstr);
            if(m.Success)
            {
                string title = m.Groups["Title"].Value;
                string price = m.Groups["Price"].Value;
            }
      

  2.   

    用js就可以取得,没必要用正则吧
    document.getElementById("J_StrPrice").innerHTML
      

  3.   


    (is)<title>(?<Title>.*?)</title>.*?<div class=\"tb-gallery\">.+?<img src = \"<img>(?Img.*?)\"/></div>?<strong id=\"J_StrPrice\" >(?<Price>.*?)</strong>
    对吗?没写过!测试不出来!
      

  4.   

    Regex re = new Regex("(?<=<title>)[\\s\\S]+?(?=</title>)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
    MatchCollection mc = re.Matches("text");
    foreach (Match ma in mc)
    {
    }
      

  5.   

    Regex re = new Regex("(?<=<strong id=\"J_StrPrice\" >)[\\d.]+(?=</strong>)", RegexOptions.IgnoreCase | RegexOptions.Multiline);
    MatchCollection mc = re.Matches("text");
    foreach (Match ma in mc)
    {
    }
    这个是价格的~
      

  6.   

    string pstr = "(?is)<title>(?<Title>.*?)</title>.*?<strong id=\"J_StrPrice\" >(?<Price>.*?)</strong>.*?<div class=\"tb-gallery\">.*?<img.*?src=\"(?<Img>[^\"]*)";//.....
                string title = m.Groups["Title"].Value;
                string price = m.Groups["Price"].Value;
                string img= m.Groups["Img"].Value;
      

  7.   

    打不开你的网址,代码风格眼熟。试试这样
    (?is)<title>(.+?)</title>(?:[^>]*>){239}(\d+(?:\.\d+)?)(?:[^>]*>){143}\s*<a href="([^"]+)分别取1,2,3就是你要的:title,价格,图片地址
    http://topic.csdn.net/u/20101008/15/d1a78275-f67f-4a9c-9b87-f9cb92615c32.html