1

Web ページhttp://cslh.cz/delegace.html?id_season=2013のテーブル class='nice'から日付、リンク テキスト、リンク href を解析したい

オブジェクトDelegationLinkを作成しました

public class DelegationLink
{
   public string date { get; set; }
   public string link { get; set; }
   public string anchor { get; set; }
}

DelegationLinkのリストを作成するためにLINQでそれを使用しました

var parsedValues =
from table in htmlDoc.DocumentNode.SelectNodes("//table[@class='nice']")
from date in table.SelectNodes("tr//td")
from link in table.SelectNodes("tr//td//a")
   .Where(x => x.Attributes.Contains("href"))
select new DelegationLink
{
   date = date.InnerText,
   link = link.Attributes["href"].Value,
   anchortext = link.InnerText,
};
return parsedValues.ToList();

日付列を1つずつ取得し、すべての行のリンク列と組み合わせますが、テーブルのすべての行を取得して、その行から日付、href、およびhreftextを取得したいだけです。私はLINQを初めて使用し、Googleを4時間使用しましたが、何の効果もありませんでした。助けてくれてありがとう。

4

1 に答える 1