如何使用 C# HtmlAgilityPack 从网站中获取以下文本?

问题描述 投票:0回答:1
c# web-scraping html-agility-pack
1个回答
0
投票

沿着以下路线:

var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);

string premium = htmlDoc.DocumentNode
    .SelectSingleNode("//div[@data-id='net_premium']").SelectSingleNode("h3[@data-app='summary-value']").InnerText;

函数中的字符串是

XPath expressions

https://html-agility-pack.net/select-single-node

http://dotnetfiddle.net/pXItfm

© www.soinside.com 2019 - 2024. All rights reserved.