이 페이지를 파싱하는 동안 약간의 문제가 발생했습니다 (실수인지 또는 버그인지 모릅니다).
나는 모든 얻으려고 이 테이블에서 사용할 수 태그 : a
그래서 이것을 달성하기 위해이 코드를 작성했습니다.
`var d = doc.GetElementbyId("odds-data-table");
HtmlNodeCollection listItems = d.SelectNodes("//a");`
특히 d
에는 내가 원하는 테이블 구조가 포함되어 있습니다.
그러나 listItems
변수는 테이블의 링크가 아니라 전체 HTML 페이지의 링크를 포함하고 있으며 이것은 매우 이상합니다. 나는 다른 경우를 시도했다 :
d.SelectNodes("a") : return null
d.SelectNodes("//a") : return all the link of the page
d.SelectNodes("/a") : return null
뭐가 잘못 되었 니? 그리고 HtmlAgilityPack 문서에 어떤 유형의 플러그인 또는 시스템을 사용 했는지도 묻습니다. 정말 감사합니다. 감사합니다.
HtmlNode
에서 각 HtmlNode
대한 Attributes
속성을 HtmlNodeCollection
한다.
HtmlDocument doc = new HtmlDocument();
var d = doc.GetElementbyId("odds-data-table");
HtmlNodeCollection listItems = d.SelectNodes(".//a");
//This list contains all your href values
List<string> hrefs = new List<string>();
foreach (var item in listItems)
{
var href = item.Attributes["href"].Value;
hrefs.Add(href);
}