从网页缓存中获取图片,将图片存放当本地文件夹中
来源:互联网 发布:sftp 修改端口号 编辑:程序博客网 时间:2024/05/17 22:28
- (void)webViewDidFinishLoad:(UIWebView *)webView{ NSArray *a=[self getImgs]; for (NSString *str in a) { NSURLCache *sharedCache = (NSURLCache *)[NSURLCache sharedURLCache]; NSURLSession *session = [NSURLSession sharedSession]; NSURLSessionDataTask *task = [session dataTaskWithURL:[NSURL URLWithString:str]]; __block NSString *wstr = str; [sharedCache getCachedResponseForDataTask:task completionHandler:^(NSCachedURLResponse * _Nullable cachedResponse) { NSString *path = [NSString stringWithFormat:@"/Users/whde/Desktop/t/%@", [wstr lastPathComponent]]; [cachedResponse.data writeToFile:path options:NSDataWritingAtomic error:nil]; }]; }}/// 获取所有图片链接- (NSArray *)getImgs{ NSMutableArray *arrImgURL = [[NSMutableArray alloc] init]; for (int i = 0; i < [self nodeCountOfTag:@"img"]; i++) { NSString *jsString = [NSString stringWithFormat:@"document.getElementsByTagName('img')[%d].src", i]; [arrImgURL addObject:[webView stringByEvaluatingJavaScriptFromString:jsString]]; } return arrImgURL;}/// 获取某个标签的结点个数- (int)nodeCountOfTag:(NSString *)tag{ NSString *jsString = [NSString stringWithFormat:@"document.getElementsByTagName('%@').length", tag]; int len = [[webView stringByEvaluatingJavaScriptFromString:jsString] intValue]; return len;}
0 0
- 从网页缓存中获取图片,将图片存放当本地文件夹中
- 从WebView缓存中获取网页图片
- Android 从WebView缓存中获取网页图片
- Android 从WebView缓存中获取网页图片
- Android 从WebView缓存中获取网页图片
- 从网页中获取图片
- 从网页中提取图片到本地
- 20.获取网络图片,将图片存储在文件,缓存中,然后先从缓存中读取,没有再从文件中读取
- c#将图片存放在dll中
- 从网络中获取图片显示,获取网页源码
- java 从网页中获取图片路径与从js中获取图片路径
- 请求图片从缓存中获取的解决方案
- 图片不存放文件夹,直接存在数据库中,
- 从ORACLE中获取图片
- 从数据库中获取图片
- 图片从dll中获取
- 从相册中获取图片
- 从网络中获取图片
- 内存管理之bootmem管理之对外分配函数
- React-Redu
- android 自定义属性
- 事务管理
- https建立连接
- 从网页缓存中获取图片,将图片存放当本地文件夹中
- PHP面向对象编程设计模式(四)观察者模式
- Quartz学习笔记(四)—— SchedulerListeners
- 进制转换的两种特殊方法
- 设计模式(多例)
- 括号匹配
- 文章标题
- 以前整理的网络上免费API接口
- 169. Majority Element