Samuli Lehtonen
Samuli Lehtonen

Reputation: 3860

Getting source code of the page with UIWebView

Hey I am making an app with the UIWebView and there are ajax things on the site. I need to run 1 ajax thing so the source code will change and after it I need to optain the source code. Anyway I could do this? Sorry if I explained it too complicatedly.

Upvotes: 7

Views: 4788

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55334

You can evaluate JavaScript within the UIWebView. Make sure to perform this after the page has completely loaded:

NSString *source = [webView stringByEvaluatingJavaScriptFromString:
                    @"document.getElementsByTagName('html')[0].outerHTML"];

Upvotes: 15

Related Questions