美文网首页
WebView与HTml

WebView与HTml

作者: LH_0811 | 来源:发表于2016-07-20 10:00 被阅读18次
     NSMutableArray  * urlImageArray = [NSMutableArray array];
      
        NSString *leng = [wb stringByEvaluatingJavaScriptFromString:@"var images = document.getElementsByTagName('img');images.length.toString();"];
        NSLog(@"leng:%@",leng);
        for (int i=0; i<[leng integerValue]; i++) {
            NSString *strimage = [NSString stringWithFormat:@"var images = document.getElementsByTagName('img');images[%d].src.toString();",i];
            NSString *ImageUrl = [wb stringByEvaluatingJavaScriptFromString:strimage];
            [urlImageArray addObject:ImageUrl];
        }
        for (NSString * url in urlImageArray) {
            NSLog(@"%@",url);
            
            NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
            UIImage * image = [UIImage imageWithData:data];
            [_picArray addObject:image];
        }
    
    

    相关文章

      网友评论

          本文标题:WebView与HTml

          本文链接:https://www.haomeiwen.com/subject/lwdvjttx.html