我想为某人开发一个应用程序,从他的Wordpress网站上阅读新闻。我试过几个像MWFeedParser这样的东西(但我不能显示图片),我经常找到一个链接:http://www.kieranmcgrady.com/blog/2012/4/25/tutorial-how-to-create-a-simple-rss-reader-for-ios.html,但这个网站过期了。
MWFeedParser非常好,但我不知道它是如何解析图片的……
有没有其他框架或者类似的框架可以方便地解析带有图片的wordpress站点?
这是我想要解析的内容:
<img src="the_url" alt="the description" width="460" height="352" class="size-full wp-image-16009 colorbox-16008" />发布于 2013-01-29 22:34:53
您不需要自己下载镜像。看一看https://github.com/rs/SDWebImage,它是一个很棒的框架,实现了延迟下载图片。您只需提供SDImageView的网址,它将在显示占位符图像的同时开始下载图像。
您可以使用NSRegularExpression从提要中提取img信息:
NSString *context = ...;
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"<img[^>]*src=['\"]([^'\"]*)['\"][^>]*>"
options:NSRegularExpressionCaseInsensitive error:&error];
NSArray *matches = [regex matchesInString:context
options: NSMatchingReportCompletion
range:NSMakeRange(0, [context length])];
NSTextCheckingResult *match = [matches objectAtIndex:0];
NSRange range = [match rangeAtIndex:1];
NSString *result = [context substringWithRange:range];请注意,在上面的代码片段中,我对img标记的格式做了一些假设。如果它不能工作,如果你能发布你得到的确切的字符串,它将会有所帮助。
https://stackoverflow.com/questions/14585329
复制相似问题