Osmosis 1.0.1

Osmosis 1.0.1

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最后发布2016年1月
SPM支持 SPM

Christian Praiß 维护。



Osmosis 1.0.1

Osmosis - Swift 渗透

描述

Osmosis 让使用 Swift 进行网络渗透变得简单。通过 Osmosis,您可以快速解析并将任何网站转换为在您的应用程序中使用数据的格式。它基于 node.js 模块 node-osmosis

使用

    Osmosis()
    // Get the website at the given url
                .get(url)
    // Find all elements matching the selector and execute the following actions on them
                .find(OsmosisSelector(selector: "#dailyScore tr.valid"), type: .CSS)
    // Populate the information you want from the dict
                .populate([
                    OsmosisPopulateKey.Single("points") : OsmosisSelector(selector: "td:nth-child(2)"),
                    OsmosisPopulateKey.Single("aircraft"): OsmosisSelector(selector: "#tt_aircraft b"),
                    OsmosisPopulateKey.Single("takeOffLocation"): OsmosisSelector(selector: ".hlinfo > b:last-child"),
                    OsmosisPopulateKey.Single("pilot"): OsmosisSelector(selector: ".hltitel a")]
                                        , type: .CSS)
    // Get the parsed information
                .list { (var dict) -> Void in
                    // Use the parsed dict here
                    print(dict)
                    }
    // Start the operations
                .start()

Osmosis 支持 XPathCSS 选择器。

安装

Osmosis 通过 CocoaPods 可用。要安装它,只需将以下行添加到您的 Podfile 中

pod "Osmosis"

作者

Christian Praiß,[email protected]

许可

Osmosis 可在 MIT 许可下获得。有关更多信息,请参阅 LICENSE 文件。