0
저는 HTML 민첩성 팩을 사용하고 class="fileHeader"
인 div
을 가지고 있으며 하위 h4 요소에 "RelayClinical Patient Education with Animations Install zip"
을 가지고 있습니다. 발견되면 특정 블록의 앵커 태그 안에 "href"
속성을 캡처하고 싶습니다. 그것을 어떻게 얻을 수 있습니까?HTML 민첩성 팩을 사용하여 다음 요소 선택
HTML 소스
<div class="fileHeader" id="fileHeader_7311111">
<h4 class="collapsed">RelayClinical Patient Education with Animations Install zip</h4>
<div class="defaultMethod">
<a class="buttonGrey" href="https://mckc-esd.subscribenet.com/cgi-bin/download?rid=2511740931&rp=DTM20130905162949MzcyODIwNjM0" title="Clicking this link will open a new window." rel="noreferrer">
HTTPS Download
</a>
</div>
</div>
코드
HtmlNodeCollection fileHeaderNodes = bodyNode.SelectNodes("//div[@class='fileHeader']//h4");
foreach (HtmlNode fileHeader in fileHeaderNodes)
{
if (fileHeader.InnerText.Trim() == "RelayClinical Patient Education with Animations Install zip")
{
HtmlNodeCollection fileHeaderNodes = bodyNode.SelectNodes("//div[@class='fileHeader']//h4");
foreach (HtmlNode fileHeader in fileHeaderNodes)
{
if (fileHeader.InnerText.Trim() == "RelayClinical Patient Education with Animations Install zip")
{
foreach (HtmlNode link in fileHeader.SelectNodes("//a[@href]"))
{
// extract the link and put in dataUrl var
if ((link.InnerText.Trim() == "HTTPS Download") && isFound == true)
{
count++;
// select all a tags (html anchor tags) that have a href attribute
HtmlAttribute att = link.Attributes["href"];
dataUrl = att.Value;
}
}
}
}
}
}
나는 쉬운 해결책이 있다는 것을 알고있었습니다. 제프가 대답 해 주셔서 감사합니다. 황금 티켓이었습니다. – user2751629