Atom-FeedKit Swift提要解析器(支持RSS,Atom,JSON Feed)

Swift 写的提要解析器里,Atom-FeedKit算是个挺顺手的工具。支持RSSAtom还有JSON Feed三种格式,解析效率还不错,调用方式也比较简单。你要是做新闻类 App 或者搞个内容同步的工具,它挺适合的。

FeedParser这部分挺贴心,传个URL进去,它直接帮你把提要搞成结构化数据。比如文章的标题、作者、摘要这些,基本一网打尽。XML、JSON 解析它都包了,不用你自己下苦功搞底层。

Swift 的类型系统在这也帮了忙,整个解析过程写起来也更安全。你不用天天担心数据类型错,代码干净,调试也轻松。像下面这个例子:

import FeedKit
let url = URL(string: "http://example.com/feed.xml")!
FeedParser(url: url) { feed, error in
  guard let feed = feed else {
    print("Error: \(error?.localizedDescription ?? \"Unknown error\")")
    return
  }
  for item in feed.items {
    print("Title: \(item.title)")
    print("Author: \(item.author)")
  }
}

基本就是这几行,连回调也设计得比较友好。你要提速开发效率,它还真帮得上。

库的结构也清晰,FeedKit-master里源码一目了然。直接拖进 Xcode 看代码,或者配合CocoaPodsCarthage拉进项目也都行。集成不麻烦,适合想快速上手的朋友。

对了,别把它和Atom 编辑器搞混了哈,名字像但没关系。FeedKit 专注提要解析,编辑器那块另说。要是你做聚合器、博客阅读器那类 App,Atom-FeedKit真的可以一试。

如果你经常跟各种网站内容打交道,想快速拿到文章数据,或者自动化做内容,那你可以考虑把它加进工具链里,省时省力。

zip
Atom-FeedKit,用swift编写的rss、atom和json提要解析器.zip 预估大小:179个文件
file
.gitignore 1KB
file
FeedKit.h 1KB
file
Contents.json 244B
file
Contents.json 62B
file
Contents.json 62B
file
Contents.json 137B
file
Contents.json 250B
file
Contents.json 62B
file
Contents.json 137B
file
Contents.json 62B
file
Contents.json 137B
file
Contents.json 137B
file
Contents.json 250B
file
Contents.json 137B
file
Contents.json 137B
file
Contents.json 515B
file
Contents.json 137B
file
Contents.json 585B
file
Contents.json 903B
file
feed.json 4KB
zip 文件大小:299.19KB