Good day, I want to parse the content from a websites table. On the Website there is a Ranking of Top Weekly Exp Players. And with the command ~weekly i want to outpot the best 20 players. For now I have the following Code:
commands.CreateCommand("weekly")
.Do(async (e) =>
{
WebClient webClient = new WebClient();
string html = webClient.DownloadString("http://combatarms.nexon.net/de/ranking/player");
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
foreach (var cell in doc.DocumentNode.SelectNodes("//table[@class='ranking_tbl']/tr/td"))
{
await e.Channel.SendMessage(cell.InnerText);
}
// await e.Channel.SendMessage("test");
});
But it doesn't shows me anything, so why im wrong?
A better thing would be that I can do an array (had it before but doesn't worked) where I can say "I only want the first <tr>
(the #), the second <tr>
(the name) and for example the 7th <tr>
(the Clanname).
But I fail with array + parsing these tr content to discord :/
For example 1 row in the table is:
<table class="ranking_tbl" summary="">
<colgroup>
<col width="80">
<col width="250">
<col width="100">
<col width="150">
<col width="100">
<col width="100">
<col width="280">
</colgroup>
<thead>
<tr>
<th></th>
<th>Name </th>
<th>Rang </th>
<th>EP </th>
<th>KDR </th>
<th>Land </th>
<th>Clan- </th>
</tr>
</thead>
<tbody>
<tr>
<td class="cell_left">1</td>
<td><a href="/de/profile/player/RADICALIST">RADICALIST</a></td>
<td><img src="http://caimage.nexoneu.com/Rank/rank_51.gif" alt=""></td>
<td>5.219.130</td>
<td>1,46</td>
<td><img src="http://caimage.nexoneu.com/Web_site/Main/img/flag/SI.png" alt=""></td>
<td><a href="/de/clan/profile/Jasmine%20Thompson">Jasmine Thompson</a></td>
</tr>