c# - Extracting the nth list item using HtmlAgilityPack -
i working on web scraper project using hmlagilitypack , c#. please have @ html code section having trouble with. since <li> items in <ul> have same class names <div> , , how can extract full location (town, city) i.e value of second <span> in second <li> item?
<ul class="menu"> <li> <div class="item"> <span class="name">name:</span> <span class="value">....</span> </div> </li> <li> <div class="item"> <span class="name">location:</span> <span class="value"> <div class="location"> <a href="....">town</a> "," <a href="....">city</a> </div> </span> </div> </li> <li> <div class="item"> <span class="name">phone:</span> <span class="value">....</span> </div> </li> </ul> this have tried , failed:
var location = adhtml.documentnode.selectnodes( @"//ul[@class='menu'] /div[@class='location'] /a").select(a => a.innertext); writing location console gives me null exception.
Comments
Post a Comment