【发布时间】:2012-02-16 19:03:07
【问题描述】:
我想从网站获取数据。我正在使用 HtmlAgilityPack (C#)。在网站内容是这样的
<div id="list">
<div class="list1">
<a href="example1.com" class="href1" >A1</a>
<a href="example4.com" class="href2" />
</div>
<div class="list2">
<a href="example2.com" class="href1" >A2</a>
<a href="example5.com" class="href2" />
</div>
<div class="list3">
<a href="example3.com" class="href1" >A3</a>
<a href="example6.com" class="href2" />
</div>
<div class="list3">
<a href="example4.com" class="href1" >A4</a>
<a href="example6.com" class="href2" />
</div>
<div class="list3">
<a href="example5.com" class="href1" >A5</a>
<a href="example6.com" class="href2" />
</div><div class="list3">
<a href="example6.com" class="href1" >A6</a>
<a href="example6.com" class="href2" />
</div><div class="list3">
<a href="example3.com" class="href1" >A7</a>
<a href="example6.com" class="href2" />
</div>
</div>
在这里,我们有 7 个链接为 class="href1"。我只想获取 3 个链接(从第 3 个链接到第 5 个链接)。如何获取这些特定链接?
【问题讨论】:
标签: c# asp.net xpath html-agility-pack