ios获取html字符串中的title
作者:
ONE2 | 来源:发表于
2022-03-28 16:58 被阅读0次NSError *error;
NSString *htmlStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://www.baidu.com"] encoding:NSUTF8StringEncoding error:&error];
if (!error && htmlStr.length) {
NSRange range = [htmlStr rangeOfString:@"(?<=title>).*(?=</title)" options:NSRegularExpressionSearch range:NSMakeRange(0, htmlStr.length - 1) locale:nil];
NSString *title = [htmlStr substringWithRange:range];
}
本文标题:ios获取html字符串中的title
本文链接:https://www.haomeiwen.com/subject/nsipjrtx.html
网友评论