Ho una pagina html che contiene una tabella e voglio analizzare quella tabella in forma di Windows C #
questa è la pagina web che voglio analizzare ho provato
> Foreach(Htmlnode a in document.getelementbyname("tr"))
{
richtextbox1.text=a.innertext;
}
Ho provato qualcosa del genere ma non mi ha dato in forma tabulare come sto semplicemente stampando tutte le trs quindi per favore aiutami riguardo a questo mi dispiace per il mio inglese.
Utilizzo del pacchetto di agilità HTML
WebClient webClient = new WebClient();
string page = webClient.DownloadString("http://www.mufap.com.pk/payout-report.php?tab=01");
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
List<List<string>> table = doc.DocumentNode.SelectSingleNode("//table[@class='mydata']")
.Descendants("tr")
.Skip(1)
.Where(tr=>tr.Elements("td").Count()>1)
.Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
.ToList();
Intendi qualcosa come questo ?
foreach (HtmlNode table in doc.DocumentNode.SelectNodes("//table")) {
///This is the table.
foreach (HtmlNode row in table.SelectNodes("tr")) {
///This is the row.
foreach (HtmlNode cell in row.SelectNodes("th|td")) {
///This the cell.
}
}
}