首页 > 代码库 > 获取UIWbview中的所有图片

获取UIWbview中的所有图片

NSString *yourHTMLSourceCodeString = [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];    NSError *error = NULL;    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(<img src=http://www.mamicode.com/"(.*?)\">)+?"                                                                           options:NSRegularExpressionCaseInsensitive                                                                             error:&error];    NSArray *matches = [regex matchesInString:yourHTMLSourceCodeString                                      options:0                                        range:NSMakeRange(0, [yourHTMLSourceCodeString length])];    NSLog(@"total matches %d",[matches count]);    for (NSTextCheckingResult *match in matches) {        NSString *img = [yourHTMLSourceCodeString substringWithRange:[match rangeAtIndex:2]] ;        NSLog(@"img src %@",img);    }