0

I need to parse the table data from the website "https://www.cmegroup.com/clearing/operations-and-deliveries/accepted-trade-types/block-data.html#contractTypes=FUT&exchanges=XCBT,XCME&assetClassId=1,6", `

I want to get the table value like 41Q9, ZQQ9, 30 Day Federal Funds Futures, FUT, CBOT, 97.92, 3500, 09:40:05

I tried to use HtmlAgilityPack and WebClient, get the table first and then try to output those value, but somehow failed. Could anyone please help me with this? Thank you very much for your help.

The html code is something like this:

`<tr class="dataRow" id="ZQQ9_FUT_CBOT_094005">
 <td width="120">41Q9</td>
 <td width="120">ZQQ9</td>
 <td class="colContract">30 Day Federal Funds Futures</td>
 <td class="colType">FUT</td>
 <td class="colExchange">CBOT</td>
 <td style="text-align:right; padding-right:15px;">97.92</td>
 <td style="text-align:right;padding-right:20px;">3500</td>
 <td style="text-align:right;">09:40:05 CT</td>
 </tr>

My code is shown as follows:

var html = @"https://www.cmegroup.com/clearing/operations-and- 
           deliveries/accepted-trade-types/block- 

data.html#contractTypes=FUT&exchanges=XCBT,XCME&assetClassId=1,6";

HtmlWeb web = new HtmlWeb();

var doc = web.Load(html);


foreach (HtmlNode table in doc.DocumentNode.SelectNodes(".//table"))
{  
    foreach (HtmlNode row in table.SelectNodes("tr"))
    {
        foreach (HtmlNode cell in row.SelectNodes("th|td"))
        {
            Console.Write(cell.InnerText);
        }
    }
}

I want to get the table value like 41Q9, ZQQ9, 30 Day Federal Funds Futures, FUT, CBOT, 97.92, 3500, 09:40:05

Kevin
  • 16,549
  • 8
  • 60
  • 74
  • [This](https://stackoverflow.com/questions/13005098/parsing-html-table-in-c-sharp) did not help you? What issue you are facing? – Chetan Jul 17 '19 at 00:51
  • I go to your link and there is no table. I have to change the filter. You sure there is always a table element? – Tyddlywink Jul 17 '19 at 00:56
  • in the loop part, I can't get the value of the table, it keeps saying that Object reference not set to an instance of an object. I think i didn't get the correct table from the website – 孙小勇 Jul 17 '19 at 01:01
  • Yeah, you might need to change the filter, like the trade date to a previous date and you can see the table. Thank you very much – 孙小勇 Jul 17 '19 at 01:02

0 Answers0