"1&vi=glance",
metrics : true,
name : 'dp_bottom_lazy',
cache : true
});
});
</script>
</div>
<hr noshade="noshade" size="1" class="bucketDivider" />
<div class="bucket">
<h2>查找其它相似商品</h2>
<div class="content">
<ul>
<li><a href="/%E5%9B%BE%E4%B9%A6/b/ref=dp_brlad_entry?ie=UTF8&amp;node=658390051">图书</a> > <a href="/%E5%B0%91%E5%84%BF%E5%9B%BE%E4%B9%A6/b/ref=dp_brlad_entry?ie=UTF8&amp;node=658409051">少儿</a> > <a href="http://www.amazon.cn/s/ref=dp_brlad_entry?ie=UTF8&rh=n%3A658734051&page=1">幼儿启蒙</a> > <a href="http://www.amazon.cn/s/ref=dp_brlad_entry?ie=UTF8&rh=n%3A660485051&page=1">汉语</a> > <a href="http://www.amazon.cn/s/ref=dp_brlad_entry?ie=UTF8&rh=n%3A663612051&page=1">拼音</a></li>
<li><a href="/%E5%9B%BE%E4%B9%A6/b/ref=dp_brlad_entry?ie=UTF8&amp;node=658390051">图书</a> > <a href="/%E5%B0%91%E5%84%BF%E5%9B%BE%E4%B9%A6/b/ref=dp_brlad_entry?ie=UTF8&amp;node=658409051">少儿</a> > <a href="/b/ref=dp_brlad_entry?ie=UTF8&amp;node=658738051">漫画、绘本</a> > <a href="http://www.amazon.cn/s/ref=dp_brlad_entry?ie=UTF8&rh=n%3A660522051&page=1">绘本</a></li>
</ul>
</div>
</div>
<hr noshade="noshade" size="1" class="bucketDivider" />
<div class="bucket">
<h2>反馈</h2>
<div class="content">产品信息有问题吗?请帮我们<b><a href="/gp/gfix/welcome.html/ref=dp_page_bottom_gfix_link?ie=UTF8&storeID=books&ASIN=B001QDT99I">更新产品信息</a></b>。</div>
</div>
 
 <br />
 
<div id="rhf">
<div class="cBox secondary">
<span class="cBoxTL"><!-- &nbsp; --></span>
"
要求结果如下(数组 或者 DataTable 都可以)图书  少儿  幼儿启蒙       汉语     拼音 
图书  少儿  漫画、绘本     绘本 

解决方案 »

  1.   

    string s = File.ReadAllText(Server.MapPath("~/test.txt"));
    MatchCollection matches = Regex.Matches(s, @"(?is)(?<=<h2>查找其它相似商品</h2>\s*<div[^>]+class=""content""[^>]*>\s*<ul>.*?)<li>.*?</li>(?=.*?</ul>\s*</div>)");
    foreach (Match match in matches)
    {
    MatchCollection anchors = Regex.Matches(match.Value, @"(?<=<a[^>]+>)[^<>]+(?=</a>)");
    foreach (Match anchor in anchors)
    Response.Write(anchor.Value + "<br/>");
    Response.Write("<br/>");
    }
    输出:
    图书
    少儿
    幼儿启蒙
    汉语
    拼音图书
    少儿
    漫画、绘本
    绘本
      

  2.   

       MatchCollection mc = Regex.Matches(href2, @"<a\s?href=(?<url>.*?)>(?<content>.*?)</a>");
                string s = "";
                foreach (Match m in mc)
                {
                    s += m.Groups["content"].Value + "\n";
                }
                MessageBox.Show(s);
      

  3.   

    (?i)(?<=<a[^>]*>)([^<]*)(?=</a>)
    结果:
    图书
    少儿
    幼儿启蒙
    汉语
    拼音
    图书
    少儿
    漫画、绘本
    绘本
    更新产品信息