Check the code bellow. I am working on a c# winform application. There i am using geckofx geckoWebBrowser
to get some html values. From following html i want to grab text- Super Deluxe Round Silver Above Ground Winter Pool Cover
but you can see what i have already tried to grab that text and that not works. Any idea whats wrong i am doing? How to fix?
c#:
url = @"https://www.homedepot.com/s/0723815359971";
geckoWebBrowser1.Navigate(url);
DateTime now = DateTime.Now;
do
{
this.Refresh();
Application.DoEvents();
} while (now.AddMilliseconds(5000) > DateTime.Now);
GeckoHtmlElement element = null;
var geckoDomElement = geckoWebBrowser1.Document.DocumentElement;
if (geckoDomElement is GeckoHtmlElement)
{
element = (GeckoHtmlElement)geckoDomElement;
innerHtml = element.InnerHtml;
title = element.GetElementsByTagName("pod-plp__brand-name")[1].NodeValue;//this is what already tried but not works
if (title != "")
{
MessageBox.Show(title);
}
}
Html:
<a class="" data-pos="0" data-request-type="sr" data-pod-type="pr" href="/p/Swimline-16-ft-x-16-ft-Round-Silver-Above-Ground-Super-Deluxe-Winter-Pool-Cover-SD12RD/305609609">
<span class="pod-plp__brand-name">Swimline</span>
Super Deluxe Round Silver Above Ground Winter Pool Cover
</a>
GetElementsByTagName
gets elements by the HTML tab name. (eg. a, span, div etc.)
Something like this ought to do it (assuming single 'a' in your document):
element.GetElementsByTagName("a")[0].FirstChild.NextSibling
Which gets the second element in the 'a', if that what you want.