Giter Club home page Giter Club logo

alamofirerssparser's Introduction

AlamofireRSSParser

CI Status Version License Platform

Requirements

  • Xcode 11.0+
  • Swift 5.1+
  • Alamofire 5.0.0+

Legacy Swift Support

If you need to support an earlier version of Swift, please either download the zip or point your Podfile at the coresponding tag:

  • Swift 4.0: tag "Swift 4.0 Final"
  • Swift 3.x: tag "2.0.1"
  • Swift 2.2: tag "Swift 2.2 Final"
  • Swift 2.3: tag "Swift 2.3 Final"

The respective readme's in those tags have more explicit instructions for using tags in CocoaPods.

Legacy Alamofire Support

If you need to support an earlier version of Alamofire, please either download the zip or point your Podfile at the coresponding tag:

  • Alamofire 4: tag "2.2.0"

Installation

Cocoapods

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

pod "AlamofireRSSParser"

Then

import AlamofireRSSParser

wherever you're using it.

Note: Since Alamofire is a dependency for AlamofireRSSParser, make sure you don't also include Alamofire in your Podile.

Manually

Alternately you can add the contents of AlamofireRSSParser/Pod/Classes/ to your project and import the classes as appropriate.

Usage

Note: To run the example project, clone the repo, and run pod install from the Example directory first.

You use AlamofireRSSParser just like any other response handler in Alamofire:

let url = "http://feeds.foxnews.com/foxnews/latest?format=xml"

AF.request(url).responseRSS() { (response) -> Void in
    if let feed: RSSFeed = response.value {
        /// Do something with your new RSSFeed object!
        for item in feed.items {
            print(item)
        }
    }
}

AlamofireRSSParser returns an RSSFeed object that contains an array of RSSItem objects.

What It Does and Doesn't Do

I think we can all admit that RSS implementations are a bit all over the place. This project is meant to parse all of the common, high level bits of the RSS 2.0 spec that people actually use/care about. It is not meant to comprehensively parse all RSS.

RSS 2.0 spec elements that it currently parses:

  • title
  • link
  • itemDescription
  • guid
  • author
  • comments
  • source
  • pubDate
  • enclosure
  • category

In addition, since this is a Swift port of what was originally the backbone of Heavy Headlines it also parses portions of the Media RSS Specification 1.5.1.

Current elements:

  • media:content
  • media: thumbnail
  • content: encoded

It also yanks all of the images that may be linked in the itemDescription (if it's HTML) and creates a nice array named imagesFromDescription that you can use for more image content.

If you need more elements parsed please file an issue or even better, please contribute! That's why this is on GitHub.

Author

Don Angelillo, [email protected]

Inspired by Thibaut LE LEVIER's awesome orginal Block RSSParser AFNetworking Plugin.

License

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

alamofirerssparser's People

Contributors

adeptusastartes avatar ayastrebov avatar lukepistrol avatar pjay avatar steve228uk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.