-1

このコードでは、varTempTxtは Html 本文コンテンツを文字列として保持し ます。ラムダ構文を使用して要素<table>または内部テキスト/html を抽出するにはどうすればよいですか?<td>

    public  string  ExtractPageValue(IWebDriver DDriver, string url="") 
    {
        if(string.IsNullOrEmpty(url))
        url = @"http://www.boi.org.il/he/Markets/ExchangeRates/Pages/Default.aspx";
        var service = InternetExplorerDriverService.CreateDefaultService(directory);
        service.LogFile = directory + @"\seleniumlog.txt";
        service.LoggingLevel = InternetExplorerDriverLogLevel.Trace;

        var options = new InternetExplorerOptions();
        options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;

        DDriver = new InternetExplorerDriver(service, options, TimeSpan.FromSeconds(60));
        DDriver.Navigate().GoToUrl(url);
        var TempTxt = DDriver.PageSource;
        return "";//Math.Round(Convert.ToDouble( TempTxt.Split(' ')[10]),2).ToString();

    }
4

1 に答える 1

1

HtmlAgilityPackを試してみてください

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);

var table = doc.DocumentNode.SelectNodes("//table/tr")
               .Select(tr => tr.Elements("td").Select(td => td.InnerText).ToList())
               .ToList();
于 2012-11-18T17:00:22.707 に答える