Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read content of Web Browser in WPF

Tags:

c#

wpf

Hello Developers I want to read external content from Website such as element between tag . I am using Web Browser Control and here is my code however this Code just fills my Web browser control with the Web Page

public MainWindow()
{
    InitializeComponent();

    wbMain.Navigate(new Uri("http://www.annonymous.com", UriKind.RelativeOrAbsolute));
}
like image 430
user1528573 Avatar asked Dec 26 '22 21:12

user1528573


1 Answers

You can use the Html Agility Pack library to parse any HTML formatted data.

HtmlDocument doc = new HtmlDocument();
doc.Load(wbMain.DocumentText);

var nodes = doc.SelectNodes("//a[@href"]);

NOTE: The method SelectNode accepts XPath, not CSS or jQuery selectors.

var node = doc.SelectNodes("id('my_element_id')");
like image 52
Tomislav Markovski Avatar answered Jan 08 '23 06:01

Tomislav Markovski