I'm trying to put the results of all the div classes named "thumb" of a finished UIWebView into one string.
I appreciate your help!
EDIT: Working Code (Problem solved):
I appreciate your help!
EDIT: Working Code (Problem solved):
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.thewebsite.com"]]];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
if (!webView.isLoading)
{
NSString *output = [self.webView stringByEvaluatingJavaScriptFromString:@"function f()"
"{"
"var theThumbs = document.getElementsByClassName('thumb');"
"var string = '';"
"for(var i=0; i < theThumbs.length; i++)"
"{"
"string +=(theThumbs[i].innerHTML);"
"}"
"return string;"
"}f()"];
NSLog(@"String is: %@", output);
}
}
Last edited: