8

I need to get all words, which are visible on screen from UIWebView. My UIWebView have html content.

Someone can help me please.

Irfan
  • 4,301
  • 6
  • 29
  • 46
Romit M.
  • 898
  • 11
  • 28
  • Are you looking for all the html of the page that is being shown, or just the html that is visible on the screen at that moment? and do you want only the text or the entire html? – Manuel May 08 '12 at 12:38
  • i want only text which is vislbe on the screen at moment. – Romit M. May 08 '12 at 12:43
  • 1
    I don't think there is a method to call where one could get this. The only way i can think of is to parse the full html and go from there. But im not sure as i have never tried something like that – Manuel May 08 '12 at 12:47
  • u found any solution for that? – Master Stroke Feb 26 '15 at 07:43

2 Answers2

9

Use following way that will give you all text of UIWebView.

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

Hope, this will help you...

Nitin
  • 7,455
  • 2
  • 32
  • 51
5

you can use

NSString *str = [self.youWebView stringByEvaluatingJavaScriptFromString:
                                  @"document.body.textContent"];
adali
  • 5,977
  • 2
  • 33
  • 40