Osmosis makes web scraping using Swift easy. With Osmosis you can quickly parse and transform any website to use its data in your app. It is based on the node.js module 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 supports both XPath and CSS selectors.
Osmosis is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Osmosis"
Christian Praiß, christian_praiss@icloud.com
Osmosis is available under the MIT license. See the LICENSE file for more info.