tags:

views:

67

answers:

1

I'm trying to reading part of HTML source code from website that has been encapsulated by javascript;basically i'm trying to read email which appears in webview but not in real source code using NSString method of 'NSString stringWithContentsOfURL:(NSURL *)url'. it looks like code showing up before hitting up the inner java script (which executes and shows the email address to show). are there any way i can get into NSString the contents that I viewed over UIWebview? I tried to use the method 'webView stringByEvaluatingJavaScriptFromString' it worked for only displaying through webview browser didn't return any string value.

Are there anyway I can get the string?

A: 

This should work in the general case:

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

Just make sure the page is loaded before you call it.

cduhn
thanks for the answer. I resolved the problem myself with convert java script into Java language and tested out what the result. and then i reconvert into objective-c language. basically what the problem was, inside of java script, one variable changes itself. seems like this value controls by server but also outter html code section has variable that also changes. what i done was, first parse off that two variables, second, i put it in javascript method which were manually converted by me. it worked great. thank you for your help.
Yoon Lee