nmdias / feedkit Goto Github PK
View Code? Open in Web Editor NEWAn RSS, Atom and JSON Feed parser written in Swift
License: MIT License
An RSS, Atom and JSON Feed parser written in Swift
License: MIT License
The URL
variable definition in the example provided in the README file should be lowercased, not to clash with the URL
class name.
This:
let URL = URL(string: "http://images.apple.com/main/rss/hotnews/hotnews.rss")!
Should be:
let url = URL(string: "http://images.apple.com/main/rss/hotnews/hotnews.rss")!
Warnings are generated by the use of "characters" and "flatMap" v. "compactMap".
Thx!
Nevermind...
Parsing links with /rss do not work and return error
Optional(Error Domain=com.feedkit.error Code=-1000 "Feed not found" UserInfo={NSLocalizedFailureReason=Couldn't parse any known feed, NSLocalizedRecoverySuggestion=Provide a valid Atom/RSS/JSON feed , NSLocalizedDescription=Feed not found})
Example link
"http://www.independent.co.uk/sport/football/rss"
it returns same error code
e.g.
FeedParser(URL: URL)?.parse({ (result) in
switch result {
case .RSS(let rssFeed):
print(rssFeed) // An `RSSFeed` model
case .Atom(let atomFeed):
print(atomFeed) // An `AtomFeed` model
case .Failure(let error):
print(error) // An `NSError` object
}
})
Should be:
FeedParser(URL: url)?.parse({ (result) in
switch result {
case .rss(let rssFeed):
print(rssFeed) // An `RSSFeed` model
case .atom(let atomFeed):
print(atomFeed) // An `AtomFeed` model
case .failure(let error):
print(error) // An `NSError` object
}
})
The library works fine with text. Is there any way to fetch images and show too?
Currently, media attributes are parsed only as part of an RSSFeedItem.
I may be wrong, but perhaps it should be possible for something like this:
<media:thumbnail width="40" height="40" url="https://secure.gravatar.com/avatar/1234"/>
to be contained inside an AtomFeedEntry
.
The XKCD atom feed at http://xkcd.com/atom.xml contains summaries like:
<summary type="html"><img src="http://imgs.xkcd.com/comics/soda_sugar_comparisons.png" title="The key is portion control, which is why I've switched to eating smaller cans of frosting instead of full bottles." alt="The key is portion control, which is why I've switched to eating smaller cans of frosting instead of full bottles." /></summary>
Note the HTML encoded "<" and ">" of the HTML content's img tag.
The "foundCharacters" XMLParser delegate callback gets called three times for this (I don't know if that is a bug in XMLParser or expected behavior):
Expected: This should go together into AtomFeedEntrySummary as "<img src="http://imgs.xkcd.com/comics/soda_sugar_comparisons.png\" title="The key is portion control, which is why I've switched to eating smaller cans of frosting instead of full bottles." alt="The key is portion control, which is why I've switched to eating smaller cans of frosting instead of full bottles.">"
Acutal: AtomFeedEntrySummary is nil
It would be awesome if FeedKit supports JSON Feed.
There is already a Swift parser for JSON Feed.
In FeedDataType.swift, line 43, new Xcode warning in v9.1:
'characters' is deprecated: Please use String or Substring directly
It seems that ESPN's RSS feed (https://www.espn.com/espn/rss/news) cannot be used to instantiate a FeedParser. I've validated that this feed url is correct and works well with other readers. Any idea as to what could cause this?
parseAsync function does not exist in library
<a class="asset-img-link" href="http://ideas.typepad.com/.a/6a00d83451bb7469e201b7c8e11fbc970b-pi\" style="display: inline;"><img alt="Brandon+saigeon1" border="0" class="asset asset-image at-xid-6a00d83451bb7469e201b7c8e11fbc970b image-full img-responsive" src="http://ideas.typepad.com/.a/6a00d83451bb7469e201b7c8e11fbc970b-800wi\" title="Brandon+saigeon1" />
after using content?.contentEncoded then after i got this data so, how can i get specific image link in this data
Hi,
Is there a way I can use the framework in my Objective-C project? I imported the FeedKit framework into my Xcode project and opened it up. I saw that it has a FeedKit-Swift.h
bridging header?
Is there a way I can use that, to call the Swift classes from my Objective-C code? For example I want to create an instance of the FeedParser class and call the FeedParser(URL: URL)?.parse
method.
Thanks for your time, Dan.
I apologize if this question is easily solvable,
In my XML document I have a custom attribute dc:creator (which specifies the author) that is also encoded in CDATA. I was wondering how I would use FeedKit with custom attributes and when they're encoded in CDATA.
Hi,
It seems a call will crash if there is no internet connection available.
Right now my setup is like this:
guard let url = URL(string: rssEndpoint) else {
print("Endpoint format invalid.")
return
}
guard let feedParser = FeedParser(URL: url) else {
print("Failed to create parser from endpoint.")
return
}
feedParser.parse({ (result) in
....
})
Where the error occurs in my second guard, when creating the parser itself.
Inspecting the error further in XCode shows that it crashes on line 56 in FeedParser.swift, in your guard statement.
If I parse data which happens to not be a valid feed, the completion block gets executed twice.
In Parser.swift, once in line 119 and once in line 242, which is, I believe an XMLParser delegate method. I don't know the FeedKit architecture enough to judge which one is superfluous, though.
One way to reproduce the error: Add this in the sample projects applicationDidFinishLaunching:
let url = URL(string: "https://tageswoche.ch")
URLSession.shared.dataTask(with: url! as URL) { (data, response, error) in
FeedParser(data: data!).parse({ (result) in
print("ERROR")
})
}.resume()
You will see that "ERROR" gets printed twice!
The way I read the README, FeedKit claims to support older RSS versions. It detects RSS 1.0 correctly based on the rdf:RDF tag. The RSSPath class however doesn't handle paths like "/rdf:RDF/channel/title". No information for the following feed can be parsed, for example:
http://rss.slashdot.org/Slashdot/slashdotMain
Hi, I've question.
How I can use this library with NSOperationQueue and is there any way to cancel FeedKit parse request.
is the XMLParser's abortParsing method appropriate for that?
Hi, while using your library I came across a feed whose xml is encoded using ISO-8859-1 instead of UTF-8. this makes the FeedDataType return nil and so does te FeedParser constructor, making it impossible to parse the feed. is there anyway you could add support for other encoding standards for xml? Thank you in advance
Hello, I have the same problem how is he here: #31 . I parse a date: <pubDate>30 Jan 2018</pubDate>
and other format <pubDate> 4 Apr 2018</pubDate>
and I get nil. Can you help me? I use Carthage.
King Regards,
Tom
Why does FeedParser.parse(_:)
take a closure when it could simply return a value?
The gist of what it does is this:
func parse(_ result: @escaping (Result) -> Void) {
self.result = result
self.parse()
...
self.result?(someResult)
}
So... why not just do this and not confuse the user?
func parse() -> Result {
self.parse()
...
return someResult
}
Better yet, dispatch your work to a background queue and make use of the interface you defined:
func parse(_ result: @escaping (Result) -> Void) {
self.result = result
DispatchQueue.global().async {
self.parse()
...
self.result?(someResult)
}
}
As far as I can tell, FeedKit only fetches the last 10 RSS items in a feed.
Is it possible/would you consider adding an index to access, for example, posts 11-20? I think an index would be the best way to solve this because having just a number of items to load option would make the first load slower. I’d rather load more items as needed.
Hello,
I have feed https://99bitcoins.com/feed/
This feed has this block
<media:content url="https://www.youtube-nocookie.com/v/zc27UFwGcZo" duration="116">
<media:player url="https://www.youtube-nocookie.com/v/zc27UFwGcZo" />
<media:title type="html">Bitcoin News Summary - October 15, 2018</media:title>
<media:description type="html">Here’s what happened this week in Bitcoin in 99 seconds. Major exchange and Tether operator, Bitfinex, has imposed a temporary ban on all fiat deposits. Clients are no longer able to deposit Euros, Dollars, Yen or Pounds to the exchange. Withdrawals are reportedly working normally. Bitfinex has sa</media:description>
<media:thumbnail url="https://99bitcoins.com/wp-content/uploads/2018/10/zc27ufwgczo.jpg" />
<media:keywords></media:keywords>
</media:content>
FeedKit can parse media:content with attributes, but can't parse inside media:content. How I can extend your parser and don't touch your code or maybe you add it?
I use CocoaPods, So I can't change your source code locally.
Maybe you can give a full block of XML and each developer can parse it, if it's not standard.
Thanks
Best Regards
OK I am using pod 6
sometimes this url: http://www.newsbtc.com/feed/
will return HTML and quickly crash 👍
FeedParser(URL: feedURL)!.parseAsync { (result) in
Normall it returns an RSS feed but through my testing it will block too many transactions and return HTML saying you need to talk to support.
Hi,
I really like your pod, it's working great except for one issue.
I'm having problems with parsing a Danish RSS feed. The strings are not coming back with correct encoding and therefore weird characters are showing up in the app.
Help would be appreciated :)
I was using the feed from: http://feeds.washingtonpost.com/rss/politics and all was fine, until today when the Washington Post's feed went offline. FeedKit crashes in the guard let statement for some reason, it isn't handling the error correctly.
I can reproduce this in your example project too by replacing the feedURL in FeedTableViewController.swift with the above Washington Post URL.
Hi! I would like to get all the items sorted by date published from 4 different RSS feeds. How would I be able to do so? Does FeedKit support dealing with multiple feeds or can you use it for only one feed?
When parsing http://feeds.feedburner.com/ubergizmo the date field is often blank even though the pubDate field contains data inside the item, and the feed seems to parse successfully. BTW I also tested this feed with the MWFeedParser code and then the date is parsed/extracted.
e.g.
<item><title>Facebook Confirms Plans To Launch A New Subscription Service</title>
<link>http://www.ubergizmo.com/2017/07/facebook-to-launch-news-subscription/?utm_source=mainrss</link>
<pubDate>20 Jul 2017 03:23:26 +0000</pubDate>
<lastmodifiedDate />
<dc:creator>Tyler Lee</dc:creator>
<category><![CDATA[General]]></category>
<category><![CDATA[Facebook]]></category>
<guid isPermaLink="false">284104</guid>
<content:encoded><![CDATA[ <p><img
class="aligncenter size-full wp-image-187417" src="http://cdn2.ubergizmo.com/wp-content/uploads/2014/02/facebook-logo.jpg" alt="" width="640" height="480" />For the most part, a lot of online publications that are free to read rely on advertisements for generating revenue. However with ad blockers becoming more widely used, and with users turning to alternative sources for their information, new ways of generating revenue need to be invented.<span
id="more-284104"></span></p><p>Subscription services are one of those methods, and it seems that publishers will soon have the <a
href="https://www.thestreet.com/story/14233293/1/facebook-s-campbell-brown-we-are-launching-a-news-subscription-product.html" target="_blank" rel="noopener">option of using Facebook as a subscription service</a>. This was confirmed by Facebook exec Campbell Brown who said, <em>“One of the things we heard in our initial meetings from many newspapers and digital publishers is that ‘we want a subscription product — we want to be able to see a paywall in Facebook,’ and that is something we’re doing now. We are launching a subscription product.”</em></p><p>The inclusion of this feature came about after news publications complained that they had little control over what their stories were being shared on the platform, and how companies such as Facebook and Google were benefiting from the work of newspapers without “fairly” compensating the publishers.</p><p>The tests for this new subscription service is expected to kick off this October, but details such as pricing have yet to be revealed, but we suppose we will have the official details in due time.</p> <a
href="http://www.ubergizmo.com/2017/07/facebook-to-launch-news-subscription/?utm_source=mainrss">Facebook Confirms Plans To Launch A New Subscription Service</a> , original content from <a
href='http://www.ubergizmo.com'>Ubergizmo</a>. Read our <a
href='http://www.ubergizmo.com/terms/'>Copyrights and terms of use</a>. <div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ubergizmo?a=5f7imQYQ90Y:3X9vkv7l_0Q:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/ubergizmo?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ubergizmo?a=5f7imQYQ90Y:3X9vkv7l_0Q:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/ubergizmo?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ubergizmo?a=5f7imQYQ90Y:3X9vkv7l_0Q:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ubergizmo?i=5f7imQYQ90Y:3X9vkv7l_0Q:gIN9vFwOqvQ" border="0"></img></a>
</div>]]></content:encoded>
</item>
What about rss media parsing?
I didn't see how I can get thumbnail from RSSFeedItem.
You can research this spec: http://www.rssboard.org/media-rss
items for test:
FeedParser
's initializer returns nil
for URLs with the feed
protocol like feed://developer.apple.com/news/rss/news.rss
.
Looks like some updates are needed for Swift 4.1.
Visible warnings:flatMap
is deprecated -> use compactMap
.
I'm not exactly sure the reasoning for the upfront fetching of the data found at "url". Most users, like myself, probably assume that parseAsync performs the fetch and parsing together.
error: type 'NSString' has no member 'stringEncoding'
error: 'Error' is not convertible to 'NSError'; did you mean to use 'as!' to force downcast?
For some reason, when trying to parse a URL in offline mode with FeedKit, the app crashes. If there's an Internet connection it works as expected.
Hello! In my app, I want to display the first 10 different items in a feed in a UICollectionView. I can only access the first item in a feed shown in your documentation. How would I be able to gather the first 10 items and add them to an array?
CocoaPods
and Carthage
are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.
It would be cool to add the Manual installation guide in your README.md
. You can take a look at my iOS Readme Template to see how you can do it.
Can we fetch and get media files easily from the description. For e.g. https://blog.google/rss/ and I want images to be fetched from description
I have specific tags in a feed adn I want to exted "RSSPath" enum and "RSSFeed + Attributes Mapper" according to my requirements. My tags aren't confirm to RSS 2.0 specifications. How I can do it easily without modifying source files? Is there any other ways?
NSURLConnection finished with error - code -1001
HTTP load failed (error code: -999 [1:89])
What should I do ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.