方法如下
- (NSArray*)httpImgUrls{
NSString* str = @"http://news.163.com";
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSString * html = [NSString stringWithContentsOfURL:[NSURL URLWithString:str] encoding:enc error:nil];
NSLog(@"%@",html);
NSArray * array = [html componentsSeparatedByString:@"\""];
NSMutableArray * imgHttps = [NSMutableArray arrayWithCapacity:100];
for (NSString * imgHttp in array) {
if ([imgHttp hasSuffix:@"jpg"]) {
[imgHttps addObject:imgHttp];
}
}
return imgHttps;
}
————————————————
版权声明:本文为CSDN博主「xuaswq」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xuaswq/article/details/47973273
网友评论