Is there a way to extract the first paragraph of each page from a UIWebView
? I'm currently struggling with this task.
I've tried using a regular expression for detection, but unfortunately it's returning the paragraph class name instead of the actual content:
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(<p\\s[\\
S]*?=\\s*?['\"](.*?)['\"][\\s\\S]*?>)+?"
options:NSRegularExpressionCaseInsensitive
error:&error];
[regex enumerateMatchesInString:html
options:0
range:NSMakeRange(0, [html length])
usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL
*stop) {
NSString *img = [html substringWithRange:[result rangeAtIndex:2]];
NSLog(@"img src %@",img);
}];
NSString *classs=[webView stringByEvaluatingJavaScriptFromString:"document.getElementbyClassName(img)"];