Copy all text from web browser control

Is it possible to clear all the text from the site the control was run to WebBrowser

without looking at the source?

+2


source to share


3 answers


You are using a property DocumentText

or WebBrowser control.

This property contains the HTML address of the site to which you went.



Update: (following comments)

If you want to parse HTML and get some of the text, I suggest you use the HTML Agility Pack .

+4


source


string browserContents = webBrowser.Document.Body.InnerText;

      



+4


source


David Walker's method is great when you don't need information from the header or non-main body of a web page. if you want something outside of the inner text, there are only two options: you need to parse "getElement". the other is the release commands (Document.ExecCommand) for the webbrowser to select all and copy to the clipboard:

wb.Document.ExecCommand("SelectAll", false, null);
wb.Document.ExecCommand("Copy", false, null);

      

then finally string content = clipboard.getText ();

Please note that spelling and syntax may be incorrect, I recall from my memory

+3


source







All Articles