zoukankan      html  css  js  c++  java
  • 获取html中所有img

    NSError *error = NULL;

        NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(<img\s[\s\S]*?src\s*?=\s*?['"](.*?)['"][\s\S]*?>)+?"

                                                                               options:NSRegularExpressionCaseInsensitive

                                                                                 error:&error];

        

        [regex enumerateMatchesInString:_article.htmlContent

                                options:0

                                  range:NSMakeRange(0, [_article.htmlContent length])

                             usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {

                                 

                                 NSString *img = [_article.htmlContent substringWithRange:[result rangeAtIndex:2]];

                                 NSLog(@"img src %@",img);

                                 if ([img rangeOfString:@"share_btn"].location == NSNotFound) {

                                     [_imagesArray addObject:img];

                                 }

                             }];

  • 相关阅读:
    函数介绍
    Php数组
    数据类型的转换
    Php 输出语句
    php运算符
    php变量
    Php 魔术常量
    HDU 2487 Ugly Windows(暴力)(2008 Asia Regional Beijing)
    codeforces 319B Psychos in a Line(模拟)
    codeforces 301D Yaroslav and Divisors(树状数组)
  • 原文地址:https://www.cnblogs.com/zengyanzhi/p/3921305.html
Copyright © 2011-2022 走看看