I'm trying to scrape website that has a "pre" tag using the HTML Agility Pack in C#. I can find plenty of "table tr td" examples but cannot find any "pre"examples. Here is my code with the formatted text "pre" inline.
private void PreformattedTextButton_Click(object sender, EventArgs e)
{
var url = @"http://www.thepredictiontracker.com/basepred.php";
var data = new MyWebClient().DownloadString(url);
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(data);
// m _ a _ e d d d d d d l n
//e h d v r 1 2 3 4 5 6 2 s
// BAL D.BUNDY TAM C.ARCHER 7.5 7.48 8.08 7.00 5.58 4.70. . 6.46
// CIN H.BAILEY ATL S.NEWCOMB 9.0 9.72 10.08 10.00 11.62 11.51. . 10.73
foreach (HtmlNode pre in doc.DocumentNode.SelectNodes("//pre"))
{
textBox1.Text += pre.InnerText + System.Environment.NewLine;
}
}
I want to capture the lines that look like the 3rd and 4th lines ignoriing the preceeding lines.
The foreach is executed, but it has pre.InnerText.Length of 1642 which is the total of the pre-formatted text. I want to capture a line of data. e.g. Line 3 & 4.
foreachloop are never executed? (i.e. thatdoc.DocumentNode.SelectNodes("//pre").GetEnumerator().MoveNext() == false) - Dai