ChristianPraiss / Osmosis

Web-Scraping with Swift made easy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Web-Scraping with Swift made easy

License:MIT License


Languages

Language:Swift 78.6%Language:Objective-C 15.0%Language:Shell 5.9%Language:Ruby 0.4%