测试测试 | ✓ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最后发布版本 | 2017年9月 |
SwiftSwift版本 | 4.0 |
SPM支持SPM | ✗ |
由Jonas Zaugg维护。
依赖于 | |
Alamofire | ~> 4.0 |
Fuzi | ~> 2.0 |
使用Fuzi的XML/HTML响应处理器,用于Alamofire
AlamoFuzi向Alamofire的DataRequest
类添加了.responseXML()
和.responseHTML()
响应处理器。两种文档类型都使用Fuzi序列化,Fuzi是Swift中解析XML/HTML的首选方法。
将AlamoFuzi添加到项目的最简单方法是使用CocoaPods。
只需将AlamoFuzi.Swift
添加到您的项目中。请注意,必须将Fuzi和Alamofire集成到您的项目中。
import Alamofire
import AlamoFuzi
Alamofire.request("http://example.org/").responseHTML { response in
switch response.result {
case .failure(let error):
debugPrint("Error: \(error)")
debugPrint(response)
case .success(let document):
// Parsing the HTML data
if let example = document.firstChild(css: "div > p") {
print(example.stringValue)
}
}
}
请注意,如果您显式使用任何Alamofire或Fuzi的类型或类,则需要导入import Alamofire
或import Fuzi
。在上面的示例中,我们没有显式使用Fuzi定义的任何类型(例如HTMLDocument
),因此不需要单独导入它。
AlamoFuzi是根据MIT许可证发布的。有关详细信息,请参阅LICENSE。