I would like to be able to extract a number from the following mark-up:
<span class="hidden" itemprop="price">17.73</span>
This HTML has thousands of lines. This mark-up has the same format always. The price can change only.
I've tried parsing the HMTL using HtmlAgilityPack
. I didn't succeed. Since the HTML format is always the same, there must be a better way to obtain the price value.
Can you give me suggestions about how to parse an HTML?
Use an XPath expression:
string x = document.SelectSingleNode(@"//span[@class='hidden' and @itemprop='price']").innerText;
where document
is an HtmlElement/HtmlDocument.DocumentNode
.
String x= webbrowser.Document.getelementsbytagname("span")[0].innerHtml
您需要在ac#中打开网页
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.