[英]How to extract data from webpage?
我想從網頁上獲取文本和數據。 當頁面加載在Web瀏覽器控件內完成時,我只想按頁面元素ID從頁面中提取文本? 請幫助我如何實現這一點,如html-agility&c#。 抱歉我的英語不好。
您可以在HtmlDocument
上使用GetElementbyId
方法,該方法允許您通過其標識符檢索某些特定的DOM元素:
string html = ... Read the HTML here
var htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.LoadHtml(html);
var element = htmlDoc.GetElementbyId("someId");
if (element != null)
{
string data = element.InnerText;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.