Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vborovikov/syndication
Feed reader library
https://github.com/vborovikov/syndication
csharp dotnet feed-reader rss rss-parser rss-reader
Last synced: 3 days ago
JSON representation
Feed reader library
- Host: GitHub
- URL: https://github.com/vborovikov/syndication
- Owner: vborovikov
- License: mit
- Created: 2024-02-21T07:43:51.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-08-07T12:43:27.000Z (3 months ago)
- Last Synced: 2024-08-07T19:46:28.414Z (3 months ago)
- Topics: csharp, dotnet, feed-reader, rss, rss-parser, rss-reader
- Language: HTML
- Homepage:
- Size: 2.04 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# Syndication
[![Downloads](https://img.shields.io/nuget/dt/SyndicationLib.svg)](https://www.nuget.org/packages/SyndicationLib)
[![NuGet](https://img.shields.io/nuget/v/SyndicationLib.svg)](https://www.nuget.org/packages/SyndicationLib)
[![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/vborovikov/syndication/blob/master/LICENSE)Syndication is a .NET library used for reading and parsing RSS and ATOM feeds. Supports **RSS 0.91, 0.92, 1.0, 2.0 and ATOM**.
Developed because tested existing libraries do not work with different languages, encodings or have other issues. Library tested with multiple languages, encodings and feeds.
Original FeedReader library is available as NuGet package:
[![NuGet](https://img.shields.io/nuget/v/CodeHollow.FeedReader.svg)](https://www.nuget.org/packages/CodeHollow.FeedReader)
## Usage
The simplest way to read a feed and show the information is:
```csharp
var feed = await FeedReader.ReadAsync("https://arminreiter.com/feed");Console.WriteLine("Feed Title: " + feed.Title);
Console.WriteLine("Feed Description: " + feed.Description);
Console.WriteLine("Feed Image: " + feed.ImageUrl);
// ...
foreach(var item in feed.Items)
{
Console.WriteLine(item.Title + " - " + item.Link);
}
```There are some properties that are only available in e.g. RSS 2.0. If you want to get those properties, the property "SpecificFeed" is the right one:
```csharp
var feed = await FeedReader.ReadAsync("https://arminreiter.com/feed");Console.WriteLine("Feed Title: " + feed.Title);
if(feed.Type == FeedType.Rss_2_0)
{
var rss20feed = (Feeds.Rss20Feed)feed.SpecificFeed;
Console.WriteLine("Generator: " + rss20feed.Generator);
}
```If the url to the feed is not known, then you can use FeedReader.GetFeedUrlsFromUrl(url) to parse the url from the html webpage:
```csharp
string url = "arminreiter.com";
var urls = FeedReader.GetFeedUrlsFromUrl(url);
string feedUrl;
if (urls.Count() < 1) // no url - probably the url is already the right feed url
feedUrl = url;
else if (urls.Count() == 1)
feedUrl = urls.First().Url;
else if (urls.Count() == 2) // if 2 urls, then its usually a feed and a comments feed, so take the first per default
feedUrl = urls.First().Url;
else
{
// show all urls and let the user select (or take the first or ...)
// ...
}var readerTask = FeedReader.ReadAsync(feedUrl);
readerTask.ConfigureAwait(false);foreach (var item in readerTask.Result.Items)
{
Console.WriteLine(item.Title + " - " + item.Link);
// ...
}
```## Specifications
- RSS 0.91: http://www.rssboard.org/rss-0-9-1-netscape
- RSS 0.92: http://backend.userland.com/rss092, http://www.rssboard.org/rss-0-9-2
- RSS 1.0 : http://web.resource.org/rss/1.0/spec
- RSS 2.0 : https://validator.w3.org/feed/docs/rss2.html
- ATOM : https://validator.w3.org/feed/docs/atom.html