I'm trying to get data from this website
I want to get: Level, Vocation and Name from the table. They are located directly in tr class -> td. How can I get those informations out? This is how data looks like:
<table width="100%" class="tabi">
<tr>
<td colspan=7>
Characters
</td>
</tr>
<tr>
<td height='30' style='background-color:#9f8f6d;'>
<a href=?page=whoisonline&ord=name&sort=DESC&id=1>↑Name</a>
</td>
<td width='240' style='background-color:#9f8f6d;'>
<a href=?page=whoisonline&ord=voc&sort=DESC&id=1>Vocation</a>
</td>
<td width='120' style='background-color:#9f8f6d;'>
<a href=?page=whoisonline&ord=lvl&sort=DESC&id=1>Level</a>
</td>
</tr>
<tr class='hover'>
<td>
<a href='?page=character&name=Abe' class='menulink_hs'>Abe</a>
</td>
<td>
Elder Druid
</td>
<td>
19
</td>
</tr>
Right now I'm stuck on getting this data out of tds using Nodes, with bad results. My htmlNodes is either NULL or it gives more than one Node(that I cant actually get out of it for some reason). What might be good solution to this?
My code:
var html = @"https://tibiantis.online/?page=whoisonline";
HtmlWeb web = new HtmlWeb();
var htmlDoc = web.Load(html);
HtmlNode htmlNodes = htmlDoc.DocumentNode.SelectSingleNode("/html/body/div[2]/table/tbody/tr[1]/td[3]/div[2]/div[2]/table/tbody/tr[3]");
foreach (var node in htmlNodes)
{
foreach (var cell in htmlNodes.SelectNodes(".//td"))
{
listBox1.Items.Add(cell.InnerText);
}
}
**I'm stuck with this .SelectNodes thing which no metter what gives me either null or too many Nodes. I tried many combinations both with .SelectSingleNode and .SelectNode **
Second thing is that I've got no clue how to get number of items that I will receive.
I was looking for the anwser on stack and google with some results, but noone of them was close to my situation