各ページの最初の段落をから取得する必要がありますUIWebView
。どうすればこれを入手できますか?
正規表現を検出するためのコードも1つありますが、段落の内容の代わりに段落クラス名が付けられています。
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(<p\\s[\\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)"];