ios获取网页源代码

NSURL *url =[NSURL URLWithString:url];
NSURLSession *session =[NSURLSession sharedSession];
__weak typeof(self)temp =self;
NSURLSessionDataTask *dataTask =[session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    NSString *retStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    NSLog(@"html = %@",retStr);
}];
[dataTask resume];

你可能感兴趣的:(ios获取网页源代码)