I want to read the website text without html tags and headers. i just need the text displayed in the web browser.
i don’t need like this
<html>
<body>
bla bla </td><td>
bla bla
<body>
<html>
i just need the text “bla bla bla bla”.
I have used the webclient and httpwebrequest methods to get the HTML content and to split the received data but it is not possible because if i change the website the tags may change.
So is there any way to get only the displayed text in the website anagrammatically?
Here is how you would do it using the HtmlAgilityPack.
First your sample HTML:
Load it up (as a string in this case):
If getting it from the web, similar:
Now select only text nodes with non-whitespace and trim them.
You can get this as a single joined string if you like:
Of course this will only work for simple web pages. Anything complex will also return nodes with data you clearly don’t want, such as javascript functions etc.