Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 2.18 KB

README.md

File metadata and controls

55 lines (41 loc) · 2.18 KB

Osmosis - Swift Scrapping

Carthage CI Status Version License Platform

Description

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

Usage

	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.

Installation

Osmosis is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Osmosis"

Author

Christian Praiß, christian_praiss@icloud.com

License

Osmosis is available under the MIT license. See the LICENSE file for more info.