<li>
   <div class="info">
   <a class="title_n" href="http://www.tootoomart.com/product-4134493-Men+the+new+Pure+paul+Sminth+Smith+sweater+16+colors+sweaters/" target="_blank"><h2>Men the new Pure paul Sminth Smith sweater 16 colors...</h2></a>
   <p class="info">Men the new Pure paul Sminth Smith sweater 16 colors sweaters</p>
   <div class="infoBox wrapClear">
   <div class="supplier">Wholesaler: <a href="/seller-jingjinghaoyun888/">jingjinghaoyun888</a> <b class="star6"><img src="http://img.ttmimg.com/www/img/090514/transparent-pixel.gif" width="16" height="16" title="Feedback Score is 1-50"/></b></div>
   <span id="isSellerOnline_jingjinghaoyun888_1"></span>
   </div>
   </div>
   <div class="priceArea">
   <p class="price1" id="price">$16.36~$16.58/Piece</p>
   <div class="items">
   <p class="price2">$163.59~$165.73/Lot</p>
   <p class="priceInfo">(10 s per lot)</p>
   </div>
   </div>
   <p class="images"><a href="http://www.tootoomart.com/product-4134493-Men+the+new+Pure+paul+Sminth+Smith+sweater+16+colors+sweaters/" title="Men the new Pure paul Sminth Smith sweater 16 colors sweaters" alt="Men the new Pure paul Sminth Smith sweater 16 colors sweaters" target="_blank"><img src="http://img.ttmimg.com/images/product/images/091219/90/0912190632381314441bmzaz_130.jpg" alt="Men the new Pure paul Sminth Smith sweater 16 colors sweaters" onload="if((this.width>=this.height)&&(this.width>=130)) {this.resized=true; this.width=130;} if((this.height>this.width)&&(this.height>=130)) {this.resized=true; this.height=130;}" onerror='this.onerror="";this.src="/images/www/nophoto_small.gif"' ptype="photo"/></a></p>
   </li>我要匹配这里面所有P标签里的字 除(10 s per lot) 和$163.59~$165.73/Lot外 和图片的src 求匹配的正则

解决方案 »

  1.   

    我需要的的<h2>里面的一个值取个名字《name1》 <p class="info">里面的值《name2》<div class="supplier">这个层里面的《a》标签的值《name3》 <p class="price1" id="price">里面的值《name4》   取<p class="images">里面的《ing》里的src 取名<name5>    这写肯定都是《li》的 
      

  2.   

    try
    <li[^>]*>.*?<h2>(?<name1>(?!</h2>).*)</h2>.*?<p(?!class).*class=['"]info['"]>(?<name2>.*?)</p>.*?<div\s*class=['"]supplier['"]>.*?<a[^>]*>(?<name3>.*?)</a>.*?<p\s*class=['"]price1['"]\s*id=['"]price['"]>(?<name4>.*?)</p>.*?<p\s*class=['"]images['"]>.*?<img\s*src=['"](?<name5>.*?)['"].*?</li>
      

  3.   

    参考楼上的高手,给你个完整的:string str = @"(?s)<li[^>]*>.*?<h2>(?<name1>(?!</h2>).*)</h2>.*?<p(?!class).*class=[""]info[""]>(?<name2>.*?)</p>.*?<div\s*class=[""]supplier[""]>.*?<a[^>]*>(?<name3>.*?)</a>.*?<p\s*class=[""]price1[""]\s*id=[""]price[""]>(?<name4>.*?)</p>.*?<p\s*class=[""]images[""]>.*?<img\s*src=[""](?<name5>.*?)[""].*?</li>";直接复制,然后取值就可以了。
      

  4.   

        string url = "http://www.tootoomart.com/wholesale-hair+removal/";
                string charset = "utf-8";
                string html = GetHtmlSource(url, charset);
                string reg =@"(?s)<li[^>]*>.*?<h2>(?<name1>(?!</h2>).*)</h2>.*?<p(?!class).*class=[""]info[""]>(?<name2>.*?)</p>.*?<div\s*class=[""]supplier[""]>.*?<a[^>]*>(?<name3>.*?)</a>.*?<p\s*class=[""]price1[""]\s*id=[""]price[""]>(?<name4>.*?)</p>.*?<p\s*class=[""]images[""]>.*?<img\s*src=[""](?<name5>.*?)[""].*?</li>";
                 Regex regex = new Regex(reg, RegexOptions.None);
                MatchCollection matchCollection = regex.Matches(html);
                for (int i = 0; i < matchCollection.Count; i++)
                {
                    Match match = matchCollection[i];
                    string name = match.Groups["name1"].Value;
                    name = name.Replace("'", "''");
                }这是代码name   里面取出来一大推HTML代码啊  不是我要的那一句啊   你们都测试时对的吗?求高手代码 
      

  5.   

    @pmars: name1和name2 取值有点问题 其他的都正常啊    还有就是上面的HTML代码只是一个商品的信息 一个页面一般有比较多的商品 怎么直接取到了最后一个商品啊  不能循环取啊