string str = File.ReadAllText(@"E:\1.txt");
            Regex reg = new Regex(@"(?is)<img[^>]*?src=""([^""]+)""[^>]*?>|(?<=<(?!font\b)[^>]*?>)(?!(?:\s*|(?:&nbsp;)*)<)([^<>]+?)(?=</?[^>]+?>)");
            foreach (Match m in reg.Matches(str))
            {
                if (m.Groups[1].Success)
                    Console.WriteLine(m.Groups[1].Value);
                else
                    Console.WriteLine(m.Groups[2].Value);
            }
在麻烦你帮我加个从页面上面获取<span class="prodList_gridViewCell"></span> 标签内的这些参数,页面有多个这样的span

解决方案 »

  1.   

    这里分了两部分来取,你试试看结果.            string str = File.ReadAllText(@"E:\1.txt");
                Regex span = new Regex(@"(?is)(?<=<span[^>]*?class=""prodList_gridViewCell""[^>]*?>).*(?=</span>)");
                Regex reg = new Regex(@"(?is)<img[^>]*?src=""([^""]+)""[^>]*?>|(?<=<(?!font\b)[^>]*?>)(?!(?:\s*|(?:&nbsp;)*)<)([^<>]+?)(?=</?[^>]+?>)");
                foreach (Match mSpan in span.Matches(str))
                {
                    foreach (Match m in reg.Matches(mSpan.Value))
                    {
                        if (m.Groups[1].Success)
                            Console.WriteLine(m.Groups[1].Value);
                        else
                            Console.WriteLine(m.Groups[2].Value);
                    }
                }
      

  2.   


    第一部分取出来的不对,不是<span class="prodList_gridViewCell">的标签也出来了 
      

  3.   


    http://www.skinstore.com/borghese.aspx?avs=Brand%7cBorghese&fa=25我只能给你连接喽,内容太多
      

  4.   

    看了下,太麻烦了,还有嵌套的.
    用了平衡组取嵌套的,然后在获取你要的数据,你看下结果是不是你要的            string str = File.ReadAllText(@"E:\1.txt");
                Regex span = new Regex(@"(?is)<span\s*class=""prodList_gridViewCell"">(?:(?!</?span).)*(?:(?:(?<Open><span[^>]*?>)(?:(?!</?span).)*)*(?:(?<-Open></span>)(?:(?!</?span).)*)*)*(?!(Open))</span>");
                Regex reg = new Regex(@"(?is)<img[^>]*?src=""([^""]+)""[^>]*?>|(?<=<(?!font\b)[^>]*?>)(?!(?:\s*|(?:&nbsp;)*)<)([^<>]+?)(?=</?[^>]+?>)");
                foreach (Match mSpan in span.Matches(str))
                {
                    foreach (Match m in reg.Matches(mSpan.Value))
                    {
                        if (m.Groups[1].Success)
                            Console.WriteLine(m.Groups[1].Value);
                        else
                            Console.WriteLine(m.Groups[2].Value);
                    }
                }
    /*
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD040-condition
    er-treatment.jpg
    Borghese Ristorativo Di Vita Conditioner Treatment for Hair and Scalp
    This lightweight botanically enriched infusion conditions the hair and scalp.
    $18.50
    8.4oz
    &nbsp;&nbsp;OD040
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD039-shampoo-t
    reatment.jpg
    Borghese Shampoo Purificante Cleansing Treatment for Hair and Scalp
    A body building formula for greater volume, substance and thickness.
    $18.50
    8.4oz
    &nbsp;&nbsp;OD039
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD036-piedi-vit
    ale.jpg
    Borghese Piedi Vitale Therapeutic Foot Creme
    Relieve tired, achy feet with this invigorating, lightweight creme.
    $21.50
    3.5oz
    &nbsp;&nbsp;OD036
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD045-fango-fir
    ma-tube.jpg
    Borghese Fango Ferma Mud Mask for Face and Body
    Skin will feel comfortably hydrated, firmer and invigorated.
    /resources/assets/badge_new.jpg
    $37.00
    7oz
    &nbsp;&nbsp;OD045
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD024-firming-s
    erum.jpg
    Borghese Siero Intensivo Intensive Firming Serum
    This lightweight serum provides moisture to the skin as it tightens and tones in
    stantly.
    $87.50
    1.5oz
    &nbsp;&nbsp;OD024
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD009-body-cont
    our-scrub.jpg
    Borghese Forma Bella Body Contour Scrub
    This cream scrub helps to speed up the cell turnover rate and diminish cellulite
    .
    $45.00
    7oz
    &nbsp;&nbsp;OD009
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD002-sponetta-
    face-body-ba.jpg
    Borghese Crema Saponetta Face and Body Bar
    Ideal for use on both the face and body, this bar leaves skin soft, moisturized
    and comfortable.
    $18.50
    11.46oz
    &nbsp;&nbsp;OD002
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD011-equalizin
    g-restorativ.jpg
    Borghese Equilibrio Equalizing Restorative
    A lightweight, oil free moisturizer that helps to normalize skin.
    $45.00
    1.7oz
    &nbsp;&nbsp;OD011
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD027-wrinkle-r
    elax.jpg
    Borghese Insta-Firm Platinum Advanced Wrinkle Relax
    This serum reduces wrinkles, smoothes away fine lines, and helps improve skin re
    siliency.
    $80.00
    1oz
    &nbsp;&nbsp;OD027
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD033-tono-body
    -lotion.jpg
    Borghese Tono Body Lotion
    Forms an invisible veil of moisture revealing healthy skin.
    $37.50
    8.4oz
    &nbsp;&nbsp;OD033
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD008-brillante
    -brightening.jpg
    Borghese CuraForte Brillante Brightening Moisture Intensifier
    This oil-free lotion helps diminish the appearance of dark spots.
    $71.00
    1.35oz
    &nbsp;&nbsp;OD008
    /resources/nav/nav_add_cart.gif
    In Stock
    //skincare-img.skinstore.com/resources/dynamic/store/indeximages/OD031-Vitamin-C
    -eye.jpg
    Borghese Cura-C Vitamin C Eye Treatment
    With daily use, dark circles, fines lines and signs of fatigue seem to disappear
    .
    $46.00
    0.5oz
    &nbsp;&nbsp;OD031
    /resources/nav/nav_add_cart.gif
    Out of Stock*/