Get all the text that is on the screen in UIWebView

I need to get all the words that are visible on the screen from UIWebView . My UIWebView has html content.

Someone can help me.

+6
source share
2 answers

Use the following method, which will give you all the text of the UIWebView .

 NSString *yourstring = [webView stringByEvaluatingJavaScriptFromString: @"document.body.innerText"]; 

Hope this helps you ...

+8
source

you can use

 NSString *str = [self.youWebView stringByEvaluatingJavaScriptFromString: @"document.body.textContent"]; 
+5
source

Source: https://habr.com/ru/post/915193/


All Articles