public async Task LoadData() { IsLoading = true; SyndicationClient client = new SyndicationClient(); var result = await client.RetrieveFeedAsync(new Uri("http://channel9.msdn.com/Feeds/RSS/mp4")); foreach (var r in result.Items.Take(12)) { try { NewsList.Add(new FeedItem { Title = r.Title.Text, Description = HtmlUtilities.ConvertToText(r.Summary.Text), ImageUrl = r.ElementExtensions.Last(e => e.NodeName == "thumbnail").AttributeExtensions[0].Value, }); } catch (Exception) { continue; } } IsLoading = false; }
public async Task<IEnumerable<News>> GetNews() { SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri("http://feeds.feedburner.com/qmatteoq_eng", UriKind.Absolute)); IEnumerable<News> news = feed.Items.Select(x => new News {Title = x.Title.Text, Summary = x.Summary.Text}); return news; }
public async Task<List<KurirNews>> ReadRssVesti(string url, NewsType tipVesti) { //string kurirUrl = "http://www.kurir.rs/rss/vesti/"; SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri(url)); List<KurirNews> kurirNews = new List<KurirNews>(); if (feed != null) { foreach (SyndicationItem item in feed.Items) { string[] slikaText = item.Summary.Text.Split(new[] { "<img src=\"", "\"><br>" }, StringSplitOptions.RemoveEmptyEntries); kurirNews.Add(new KurirNews() { Id = IdCounter++, ImagePath = slikaText.Length > 0 ? slikaText[0] : "", Summary = slikaText.Length > 1 ? slikaText[1] : "", PublishedDateTime = item.PublishedDate.DateTime, Title = item.Title.Text, Url = item.Links[0].NodeValue ?? item.Id, NewsType = tipVesti.ToString() }); } } return kurirNews; }
/// <summary> /// Get Articles From Feed /// </summary> /// <param name="feedUrl"></param> /// <returns></returns> public static async Task<ArticleList> GetArticleListFromFeedAsync(string feedUrl) { var syncClient = new SyndicationClient(); var lista = new ArticleList(); if (InternetConectivity) { var feed = await syncClient.RetrieveFeedAsync(new Uri(feedUrl)); foreach (var art in feed.Items) { var content = CreateContent(art.NodeValue); lista.Add(new Article() { Title = art.Title.Text, Content = content, Summary = CreateSummary(art.Summary, content), ImgUri = Find1stImageFromHtml(content) }); } } else { throw new Exception(INTERNET_REQUIRED); } return lista; }
private async void getDataFromURL(string url) { //SyndicationFeed feed = new SyndicationFeed(); SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri(url)); listRSSItem = new List<SyndicationItem>(); foreach (SyndicationItem item in feed.Items) { gridView.Items.Add(item.Title.Text+"\n"+item.Summary.Text); string tmp = item.Title.Text; string[] date = tmp.Split(' '); string currentDate = date[7]; string[] processDate = currentDate.Split('/'); string addDate = processDate[0] + '/' + processDate[1] + '/' + "2016"; //listDate.Add(addDate, item.Summary.Text); listRSSItem.Add(item); if (listDate.ContainsKey(addDate)) { listDate.Clear(); } else { listDate.Add(addDate, item.Summary.Text); } } lastest.Items.Clear(); lastest.Items.Add(listRSSItem.First().Title.Text+'\n'+listRSSItem.First().Summary.Text); }
// ref: Building a Windows 8 RSS Reader // http://visualstudiomagazine.com/articles/2012/01/04/building-a-windows-8-rss-reader.aspx /// <summary> /// RSS 주소에서 피드 가져오기. /// </summary> /// <param name="url"></param> /// <param name="maxItems"></param> /// <returns></returns> public async Task<RSSFeed> GetFeeds(string url, int maxItems = 10) { var feeds = new RSSFeed(); var client = new SyndicationClient(); var feedUri = new Uri(url); SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); var topFeeds = feed.Items.OrderByDescending(x => x.PublishedDate).Take(maxItems).ToList(); feeds.Title = feed.Title.Text; foreach (var item in topFeeds) { var feedItem = new RSSItem { Title = item.Title.Text, PublishedOn = item.PublishedDate.DateTime }; var authors = from a in item.Authors select a.Name; feedItem.Author = String.Join(",", authors); feedItem.Content = item.Content != null ? item.Content.Text : String.Empty; feedItem.Description = item.Summary != null ? item.Summary.Text : String.Empty; var links = from l in item.Links select new RSSLink(l.Title, l.Uri); feedItem.Links = links.ToList(); feeds.Items.Add(feedItem); } return feeds; }
public RssFeed(string feedUrl) { this.FeedUrl = new Uri(feedUrl); this.syndicationClient = new SyndicationClient(); this.feed = null; var feedPromise = GetFeed(); }
public static async Task<List<FeedItem>> getFeedsAsync(string url) { //The web object that will retrieve our feeds.. SyndicationClient client = new SyndicationClient(); //The URL of our feeds.. Uri feedUri = new Uri(url); //Retrieve async the feeds.. var feed = await client.RetrieveFeedAsync(feedUri); //The list of our feeds.. List<FeedItem> feedData = new List<FeedItem>(); //Fill up the list with each feed content.. foreach (SyndicationItem item in feed.Items) { FeedItem feedItem = new FeedItem(); feedItem.Content = item.Summary.Text; feedItem.Link = item.Links[0].Uri; feedItem.PubDate = item.PublishedDate.DateTime; feedItem.Title = item.Title.Text; try { feedItem.Author = item.Authors[0].Name; } catch (ArgumentException) { } feedData.Add(feedItem); } return feedData; }
/// <summary> /// Creates the syndicationClient Object that loads the given News Feed. /// </summary> /// <returns>List of Syndication Items</returns> public async Task<IList<SyndicationItem>> LoadNewsAsync(Uri uri) { SyndicationClient syndicationClient = new SyndicationClient(); var feeds = await syndicationClient.RetrieveFeedAsync(uri); return feeds.Items; }
private async void k_Click_1(object sender, RoutedEventArgs e) { SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri("http://mohammedemam.wordpress.com/feed/"); var feed = await client.RetrieveFeedAsync(feedUri); FeedData feedData = new FeedData(); foreach (SyndicationItem item in feed.Items) { FeedItem feedItem = new FeedItem(); feedItem.Title = item.Title.Text; feedItem.PubDate = item.PublishedDate.DateTime; feedItem.Author = item.Authors[0].Name; // Handle the differences between RSS and Atom feeds. if (feed.SourceFormat == SyndicationFormat.Atom10) { feedItem.Content = item.Content.Text; feedItem.Link = new Uri("http://mohammedemam.wordpress.com/feed/" + item.Id); } else if (feed.SourceFormat == SyndicationFormat.Rss20) { feedItem.Content = item.Summary.Text; feedItem.Link = item.Links[0].Uri; } feedData.Items.Add(feedItem); } ItemListView.DataContext = feedData.Items; }
private async Task GetRssDataAsync() { if (this._groups.Count != 0) return; SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri("http://habrahabr.ru/rss/hub/bitcoin/"); var feed = await client.RetrieveFeedAsync(feedUri); foreach (SyndicationItem item in feed.Items) { string data = string.Empty; if (feed.SourceFormat == SyndicationFormat.Atom10) { data = item.Content.Text; } else if (feed.SourceFormat == SyndicationFormat.Rss20) { data = item.Summary.Text; } Regex regx = new Regex("http://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?.(?:jpg|bmp|gif|png)", RegexOptions.IgnoreCase); string filePath = regx.Match(data).Value; DataGroup group = new DataGroup(item.Id, item.Title.Text, item.Links[0].Uri.ToString(), filePath.Replace("small", "large"), data.Split(new string[] { "<br>" }, StringSplitOptions.None)[1].ToString()); this.Groups.Add(group); } }
public async Task RetrieveFeedAsync (string feedUriString) { Debug.WriteLine ("Retrieving feed. (" + feedUriString + ")"); var syndicationClient = new SyndicationClient (); var feedUri = new Uri (feedUriString); var feed = new FeedData (); try { var syndicationFeed = await syndicationClient.RetrieveFeedAsync (feedUri); if (syndicationFeed.Title != null && syndicationFeed.Title.Text != null) { feed.Title = syndicationFeed.Title.Text; } if (syndicationFeed.Subtitle != null && syndicationFeed.Subtitle.Text != null) { feed.Description = syndicationFeed.Subtitle.Text; } if (syndicationFeed.Items != null && syndicationFeed.Items.Count > 0) { feed.PublishedDate = syndicationFeed.Items[0].PublishedDate.DateTime; foreach (var syndicationFeedItem in syndicationFeed.Items) { feed.Entries.Add (_ReadFeedDataEntryFrom (syndicationFeedItem, syndicationFeed.SourceFormat)); } } } catch (Exception) { } //lock (_Feeds) { // _Feeds.Add (feed); //} _Feeds.Add (feed); }
private async Task GetSampleDataAsync() { if (this._groups.Count != 0) return; SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri("http://rss.zol.com.cn/mobile_toutiao.xml"); var feed = await client.RetrieveFeedAsync(feedUri); foreach (SyndicationItem item in feed.Items) { string data = string.Empty; if (feed.SourceFormat == SyndicationFormat.Atom10) { data = item.Content.Text; } else if (feed.SourceFormat == SyndicationFormat.Rss20) { data = item.Summary.Text; } Regex regx = new Regex("http://([\\w+?\\.\\w+])+([a-zA-Z0-9\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)_\\-\\=\\+\\\\\\/\\?\\.\\:\\;\\'\\,]*)?.(?:jpg|bmp|gif|png)", RegexOptions.IgnoreCase); string filePath = regx.Match(data).Value; string description = GetDescription(data); DataGroup group = new DataGroup(item.Links[0].Uri.ToString(), item.Title.Text.Replace(" "," "), item.Links[0].Uri.ToString(), filePath, description); this.Groups.Add(group); } }
private async void AppBarButton_Click(object sender, RoutedEventArgs e) { var client = new SyndicationClient(); var uri = new Uri("http://feeds.bbci.co.uk/news/rss.xml"); var feed = await client.RetrieveFeedAsync(uri); DataContext = feed; }
public async Task<FeedData> GetFeedAsync(string link) { Windows.Web.Syndication.SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(link); try { SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); // This code is executed after RetrieveFeedAsync returns the SyndicationFeed. // Process the feed and copy the data you want into the FeedData and FeedItem classes. FeedData feedData = new FeedData(); if (feed.Title != null && feed.Title.Text != null) { feedData.Title = feed.Title.Text; } if (feed.Subtitle != null && feed.Subtitle.Text != null) { feedData.Description = feed.Subtitle.Text; } if (feed.Items != null && feed.Items.Count > 0) { // Use the date of the latest post as the last updated date. feedData.PubDate = feed.Items[0].PublishedDate.DateTime; foreach (SyndicationItem item in feed.Items) { FeedItem feedItem = new FeedItem(); if (item.Title != null && item.Title.Text != null) { feedItem.Title = item.Title.Text; } if (item.PublishedDate != null) { feedItem.PubDate = item.PublishedDate.DateTime; } if (item.Authors != null && item.Authors.Count > 0) { feedItem.Author = item.Authors[0].Name.ToString(); } // Handle the differences between RSS and Atom feeds. if (feed.SourceFormat == SyndicationFormat.Atom10) { if (item.Content != null && item.Content.Text != null) { feedItem.Content = item.Content.Text; } if (item.Id != null) { feedItem.Link = new Uri(item.Id); } } else if (feed.SourceFormat == SyndicationFormat.Rss20) { if (item.Summary != null && item.Summary.Text != null) { feedItem.Content = item.Summary.Text; } if (item.Links != null && item.Links.Count > 0) { feedItem.Link = item.Links[0].Uri; } } feedData.Items.Add(feedItem); } } return feedData; } catch (Exception) { return null; } }
public async Task RefreshAsync(string url) { Uri uri; if (!Uri.TryCreate(url, UriKind.Absolute, out uri)) return; bi.IsActive = true; string errorMessage = null; var client = new SyndicationClient(); client.BypassCacheOnRetrieve = true; // Although most HTTP servers do not require User-Agent header, // others will reject the request or return a different response if this header is missing. // Use SetRequestHeader() to add custom headers. client.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"); try { var feed = await client.RetrieveFeedAsync(uri); var ds = feed.Items.Select(item => new RssItem() { Url = item.Links.Count > 0 ? item.Links[0].Uri.AbsoluteUri : string.Empty, Title = item.Title != null ? item.Title.Text : "(no title)", Author = item.Authors.Count > 0 ? item.Authors[0].NodeValue : "(no author)", Published = item.PublishedDate.DateTime, Content = item.Content != null ? item.Content.Text : (item.Summary != null ? item.Summary.Text : "(no content)") }); gvRss.ItemsSource = ds; } catch (Exception ex) { //SyndicationErrorStatus status = SyndicationError.GetStatus(ex.HResult); //if (status == SyndicationErrorStatus.InvalidXml) // OutputField.Text += "An invalid XML exception was thrown. Please make sure to use a URI that points to a RSS or Atom feed."; //if (status == SyndicationErrorStatus.Unknown) //{ // WebErrorStatus webError = WebError.GetStatus(ex.HResult); // if (webError == WebErrorStatus.Unknown) // { // // Neither a syndication nor a web error. Rethrow. // throw; // } //} errorMessage = ex.Message; } bi.IsActive = false; if (!string.IsNullOrEmpty(errorMessage)) await Utils.MessageBox(errorMessage); }
private async void GetFeed_Click(object sender, RoutedEventArgs e) { OutputField.Text = ""; // By default 'FeedUri' is disabled and URI validation is not required. When enabling the text box // validating the URI is required since it was received from an untrusted source (user input). // The URI is validated by calling Uri.TryCreate() that will return 'false' for strings that are not valid URIs. // Note that when enabling the text box users may provide URIs to machines on the intrAnet that require // the "Home or Work Networking" capability. Uri uri; if (!Uri.TryCreate(FeedUri.Text.Trim(), UriKind.Absolute, out uri)) { rootPage.NotifyUser("Error: Invalid URI.", NotifyType.ErrorMessage); return; } SyndicationClient client = new SyndicationClient(); client.BypassCacheOnRetrieve = true; // Although most HTTP servers do not require User-Agent header, others will reject the request or return // a different response if this header is missing. Use SetRequestHeader() to add custom headers. client.SetRequestHeader("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"); rootPage.NotifyUser("Downloading feed...", NotifyType.StatusMessage); OutputField.Text = "Downloading feed: " + uri.ToString() + "\r\n"; try { currentFeed = await client.RetrieveFeedAsync(uri); rootPage.NotifyUser("Feed download complete.", NotifyType.StatusMessage); DisplayFeed(); } catch (Exception ex) { SyndicationErrorStatus status = SyndicationError.GetStatus(ex.HResult); if (status == SyndicationErrorStatus.InvalidXml) { OutputField.Text += "An invalid XML exception was thrown. " + "Please make sure to use a URI that points to a RSS or Atom feed."; } if (status == SyndicationErrorStatus.Unknown) { WebErrorStatus webError = WebError.GetStatus(ex.HResult); if (webError == WebErrorStatus.Unknown) { // Neither a syndication nor a web error. Rethrow. throw; } } rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage); } }
private async void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri("http://mohammedemam.wordpress.com/feed/"); var feed = await client.RetrieveFeedAsync(feedUri); FeedItem f = new FeedItem(); f.Link = feed.Items[ItemListView.SelectedIndex].Links[0].Uri; web.Navigate(f.Link); web.Visibility = Visibility.Visible; }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { var client = new SyndicationClient(); var uri = new Uri("http://feeds.bbci.co.uk/news/rss.xml"); var feed = await client.RetrieveFeedAsync(uri); TitleImage.Source = new BitmapImage(feed.ImageUri); TitleTextBlock.Text = feed.Title.Text; }
private async void AppBarButton_Click(object sender, RoutedEventArgs e) { var client = new SyndicationClient(); var uri = new Uri("http://feeds.bbci.co.uk/news/rss.xml"); var feed = await client.RetrieveFeedAsync(uri); TitleTextBlock.Text = feed.Title.Text; TitleImage.Source = new BitmapImage(feed.ImageUri); ItemsGridView.ItemsSource = feed.Items; }
private async Task<FeedData> GetFeedAsync(string feedUriString) { SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(feedUriString); try { SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); FeedData feedData = new FeedData(); if (feed.Title != null && feed.Title.Text != null) feedData.Title = feed.Title.Text; if (feed.Subtitle != null && feed.Subtitle.Text != null) feedData.Description = feed.Subtitle.Text; if (feed.Items != null && feed.Items.Count > 0) { feedData.PubDate = feed.Items[0].PublishedDate.DateTime; foreach (SyndicationItem item in feed.Items) { FeedItem feedItem = new FeedItem(); if (item.Title != null && item.Title.Text != null) feedItem.Title = item.Title.Text; if (item.PublishedDate != null) feedItem.PubDate = item.PublishedDate.DateTime; if (item.Authors != null && item.Authors.Count > 0) feedItem.Author = item.Authors[0].Name.ToString(); if (feed.SourceFormat == SyndicationFormat.Atom10) { if (item.Content != null && item.Content.Text != null) feedItem.Content = item.Content.Text; if (item.Id != null) feedItem.Link = new Uri("http://www.microsoft.com"); } else if (feed.SourceFormat == SyndicationFormat.Rss20) { if (item.Summary != null && item.Summary.Text != null) feedItem.Content = item.Summary.Text; if (item.Links != null && item.Links.Count > 0) feedItem.Link = item.Links[0].Uri; } feedData.Items.Add(feedItem); } } return feedData; } catch (Exception) { return null; } }
public async Task<USFBlogDataSource> GetBlogFeedsAsync(string aFeedUri) { SyndicationClient client = new SyndicationClient(); SyndicationFeed feedObject; Uri FeedUri = new Uri(aFeedUri); try { feedObject = await client.RetrieveFeedAsync(FeedUri); USFBlogFeed feedData = new USFBlogFeed(); feedData.Title = feedObject.Title.Text; feedData.PubDate = feedObject.Items[0].PublishedDate.DateTime; if (feedObject.Subtitle != null) { feedData.Description = feedObject.Subtitle.Text; } if (feedObject.Items != null && feedObject.Items.Count > 0) { int currentitem = 0; feedData.PubDate = feedObject.Items[0].PublishedDate.DateTime; foreach (SyndicationItem feedItem in feedObject.Items) { currentitem++; BlogFeedItem blogFeedItem = new BlogFeedItem(); blogFeedItem.Author = feedItem.Authors[0].Name; blogFeedItem.Title = feedItem.Title.Text; blogFeedItem.PubDate = feedItem.PublishedDate.DateTime; if (feedObject.SourceFormat == SyndicationFormat.Rss20) { if (feedItem.Summary != null) { blogFeedItem.Content = feedItem.Summary.Text; } if (feedObject.Links != null) blogFeedItem.FeedLink = feedItem.Links[0].Uri; if (feedObject.SourceFormat == SyndicationFormat.Atom10) { if (feedItem.Summary != null) { blogFeedItem.Content = feedItem.Content.Text; blogFeedItem.FeedLink = new Uri(FeedUri.ToString() + currentitem.ToString()); } } } } } } catch (Exception ex) { ;} }
public MainPageViewModel(IDataRepository dataRepository, INavigationService navService, IEventAggregator eventAggr) { _dataRepository = dataRepository; MainText = "Runtime Text"; _eventAggr = eventAggr; //NavigateCommand = new DelegateCommand(() => navService.Navigate("UserInput", null)); DownloadBtnTouched = new DelegateCommand(async() => { Windows.Web.Syndication.SyndicationClient client = new SyndicationClient(); try { var txt = await MyTestAsyncClass.MyMethodAsync(); } catch(Exception e) { Debug.WriteLine(e.Message); } // Force the SyndicationClient to download the information. client.BypassCacheOnRetrieve = true; Uri feedUri = new Uri("http://blogs.windows.com/feed/"); //"http://windowsteamblog.com/windows/b/windowsexperience/atom.aspx"); try { // Call SyndicationClient RetrieveFeedAsync to download the list of blog posts. SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); // The rest of this method executes after await RetrieveFeedAsync completes. var Text = feed.Title.Text + Environment.NewLine; foreach (SyndicationItem item in feed.Items) { Text += item.Title.Text + ", " + item.PublishedDate.ToString() + Environment.NewLine; } } catch (Exception ex) { // Log Error. //rssOutput.Text = // "I'm sorry, but I couldn't load the page," + // " possibly due to network problems." + // "Here's the error message I received: " // + ex.ToString(); } }); }
public async Task Refresh() { DataContext = null; var client = new SyndicationClient(); var uri = new Uri("http://feeds.bbci.co.uk/news/rss.xml"); var feed = await client.RetrieveFeedAsync(uri); DataContext = feed; }
public async void AddElement(Uri blogUri, string categoryName) { _i_GetBlogs++; System.Threading.Tasks.Task task = new System.Threading.Tasks.Task( async() =>{ if (categoryName == "" || categoryName == null) categoryName = strCommon; else AddCategoryList(categoryName); FB_Category fb_cate = CategoryFind(categoryName); SyndicationClient client = new SyndicationClient(); Uri feedUri = blogUri; SyndicationFeed feed;// = await client.RetrieveFeedAsync(feedUri); try { // 비정상 적으로 받았을 경우 feed = await client.RetrieveFeedAsync(feedUri); } catch (Exception) { _b_Error = true; _i_GetBlogs--; return; } // This code is executed after RetrieveFeedAsync returns the SyndicationFeed. // Process it and copy the data we want into our FeedData and FeedItem classes. FB_Blog feedData = new FB_Blog(); feedData.Title = feed.Title.Text; feedData.BlogUri = feedUri; feedData.ImageUri = feed.ImageUri; if (feed.Subtitle != null && feed.Subtitle.Text != null) { feedData.Description = feed.Subtitle.Text; } // Use the date of the latest post as the last updated date. feedData.PubDate = feed.Items[0].PublishedDate.DateTime; feedData.ReadLastDate = DateTime.Now; feedData.CategoryName = fb_cate; fb_cate.FB_Blogs.Add(feedData); Ori_Blogs.Add(feedData); await FeedPost(feedData); _i_GetBlogs--; }); task.Start(); // 동기화 시켜주기 위해서 기다리는 명령줄 while (_i_GetBlogs != 0) { new System.Threading.ManualResetEvent(false).WaitOne(10); } }
public async Task<RssFeed> GetFeedAsync(String feedUri) { SyndicationClient client = new SyndicationClient(); Uri uri = new Uri(feedUri); SyndicationFeed syndicationFeed = await client.RetrieveFeedAsync(uri); RssFeed feed = new RssFeed(); feed.ParseSyndicationFeed(syndicationFeed); return feed; }
private async void load(Windows.UI.Xaml.Controls.ItemsControl list, Uri uri) { SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(uri); if (feed != null) { foreach (SyndicationItem item in feed.Items) { list.Items.Add(item); } } }
public async Task<IEnumerable<FeedItem>> GetNews(string feedUrl) { SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri(feedUrl, UriKind.Absolute)); List<FeedItem> feedItems = feed.Items.Select(x => new FeedItem { Title = x.Title.Text, Description = x.Summary.Text, PublishDate = x.PublishedDate }).ToList(); return feedItems; }
private async Task<FeedData> GetFeedAsync(String feedUriString) { SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(feedUriString); try { SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); // This code is executed after RetrieveFeedAsync returns the SyndicationFeed. // Process it and copy the data we want into our FeedData and FeedItem classes. FeedData feedData = new FeedData(); feedData.Title = feed.Title.Text; if (feed.Subtitle != null && feed.Subtitle.Text != null) { feedData.Description = feed.Subtitle.Text; } feedData.PubDate = feed.Items[0].PublishedDate.DateTime; foreach (SyndicationItem item in feed.Items) { FeedItem feedItem = new FeedItem(); feedItem.Title = item.Title.Text; feedItem.PubDate = item.PublishedDate.DateTime; feedItem.Author = item.Authors[0].Name.ToString(); if (feed.SourceFormat == SyndicationFormat.Atom10) { feedItem.Content = item.Summary.Text; feedItem.Link = new Uri("http://windowsteamblog.com" + item.Id); } else if (feed.SourceFormat == SyndicationFormat.Rss20) { feedItem.Content = item.Summary.Text; feedItem.Link = item.Links[0].Uri; } feedData.Items.Add(feedItem); } return feedData; } catch (Exception) { return null; } }
// Sample Address: http://www.izsu.gov.tr/Pages/rss.aspx?rssId=3 private async void OkBtn_Click(object sender, RoutedEventArgs e) { Uri uri = new Uri(UrlBox.Text); SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(uri); if (feed != null) { foreach (SyndicationItem item in feed.Items) { // Summary = Description listBox.Items.Add(item.Title.Text + " - " + item.Summary.Text); } } }
private async void PodList_ItemClick(object sender, ItemClickEventArgs e) { Windows.Web.Syndication.SyndicationClient client = new Windows.Web.Syndication.SyndicationClient(); Windows.Web.Syndication.SyndicationFeed feed; Podcast poddy = e.ClickedItem as Podcast; string feedName = poddy.stationURL; Uri rssFeed = new Uri(feedName); try { feed = await client.RetrieveFeedAsync(rssFeed); PushFeedToDetails(feed); } catch { await Show_Error_Dialog("There's a problem downloading that feed. " + "If you're connected to the Internet, double-check the RSS URL."); } }