public static List <Tweet> GetTweets(string _TwitterUser) { List <Tweet> resultTweets = new List <Tweet>(); try { string rssAddress = "http://twitrss.me/twitter_user_to_rss/?user=" + _TwitterUser; System.Xml.XmlReader reader = System.Xml.XmlReader.Create(rssAddress); System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader); reader.Close(); foreach (System.ServiceModel.Syndication.SyndicationItem item in feed.Items) { Tweet newTweet = new Tweet(); newTweet.m_Creator = _TwitterUser; newTweet.m_Text = item.Title.Text; newTweet.m_TweetLink = item.Id; newTweet.m_PostDate = item.PublishDate.UtcDateTime; resultTweets.Add(newTweet); } } catch (Exception) {} return(resultTweets); }
public RSSFeed(Uri urlfeed) { _urlfeed = urlfeed.ToString(); _reader = System.Xml.XmlReader.Create(urlfeed.ToString(), null); _namespace = System.Xml.Linq.XNamespace.Get("http://purl.org/rss/1.0/modules/content/"); _rss_feed = System.ServiceModel.Syndication.SyndicationFeed.Load(_reader); _rss_posts = _GetBlogFeeds().ToArray <RSSPost>(); }
public RSSFeed(Uri urlfeed) { _urlfeed = urlfeed.ToString(); _reader = System.Xml.XmlReader.Create(urlfeed.ToString(), null); _namespace = System.Xml.Linq.XNamespace.Get("http://purl.org/rss/1.0/modules/content/"); _rss_feed = System.ServiceModel.Syndication.SyndicationFeed.Load(_reader); _rss_posts = _GetBlogFeeds().ToArray<RSSPost>(); }
public async Task FetchAsyncNullList() { var orchestrator = new FeedOrchestrator("Name", "Description"); orchestrator.ClearCache(); System.ServiceModel.Syndication.SyndicationFeed feed = await orchestrator.GetFeedAsync(null, false); Assert.IsTrue(feed.Items.Count() == 0); Assert.AreEqual("Name", feed.Title.Text); }
public async Task FetchAsyncEmptyListForce() { var orchestrator = new FeedOrchestrator("Name", "Description"); orchestrator.ClearCache(); var feedInfos = new List <FeedInfo>(); System.ServiceModel.Syndication.SyndicationFeed feed = await orchestrator.GetFeedsAsync(feedInfos, false); Assert.IsTrue(feed.Items.Count() == 0); Assert.AreEqual("Name", feed.Title.Text); }
public FeedNoticias ObterFeedNoticias() { //Instancia a Classe de retono da Model FeedNoticias retornoFeed = new FeedNoticias(); //Obtem a url do Feed localizado no web.config string PathFeed = System.Configuration.ConfigurationManager.AppSettings["FeedMinutoURL"].ToString(); //Cria a variavel referente ao xml localizado na url em questao using (var reader = System.Xml.XmlReader.Create(PathFeed)) { //Efetua a leitura do feed de noticias System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader); var Palavras = new List <string>(); int QuantidadeFeeds = int.Parse(System.Configuration.ConfigurationManager.AppSettings["NumeroFeeds"].ToString()); int PalavrasResumo = int.Parse(System.Configuration.ConfigurationManager.AppSettings["NumeroPalavrasResumo"].ToString()); //Obtem os ultimos tópicos do feed de acordo com a configuracao no web.config (10) foreach (var item in feed.Items.Take(QuantidadeFeeds).OrderByDescending(x => x.PublishDate)) { //Obtem a lista de palavras desconsiderando as preposicoes var ListaPalavas = ObtemPalavras(item.Summary.Text); //Adiciona ao objeto a lista de palavras do topico Palavras.AddRange(ListaPalavas); //Adiciona ao objeto de retorno os feeds mais atuais retornoFeed.ListaFeed.Add(new DadosFeed(item.Title.Text, item.PublishDate, item.Summary.Text, ListaPalavas.Count())); } //Faz uma consulta no objeto para quantificar as palavras utilizadas em todos os topicos var resultado = from p in Palavras group p by p into g select new { palavra = g.Key, contador = g.Count() }; //Percorre o objeto de forma decrescente e obtem o numero de registros de acordo com a configuracao no web.config (10) foreach (var registo in resultado.OrderByDescending(x => x.contador).Take(PalavrasResumo)) { //Adiciona ao objeto de retorno o resumo das palavras mais utilizadas e quantas vezes se repetem retornoFeed.ListaResumo.Add(new ResumoFeed(registo.palavra, registo.contador)); } } return(retornoFeed); }
private void ShowFeed() { try { if (!isNetWorkConnection()) { MessageBox.Show("Sem conexão com a internet!", "Alerta!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } using (var reader = System.Xml.XmlReader.Create("http://g1.globo.com/dynamo/economia/rss2.xml")) { System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader); foreach (var item in feed.Items) { int s, f; string noticia = "NOTÍCIA: " + item.Title.Text; noticia += "\n"; noticia += string.Format("FONTE: {0}", item.Links.First().Uri.ToString()); noticia += "\n"; if (item.Summary != null) { //noticia += item.Summary.Text; s = item.Summary.Text.IndexOf("<"); f = item.Summary.Text.IndexOf(">"); if (f != -1) { noticia += item.Summary.Text.Substring(f + 7); } } noticia += "\n______________________________________________________________________________"; noticia += "______________________________________________________________________________"; noticia += "______________________________________________________________________________"; noticia += "______________________________________________________________________________"; lsFeed.Items.Add(noticia); } } } catch (Exception) { MessageBox.Show("Não é possivel carregar notícias, contacte o administrador!", "Informação", MessageBoxButton.OK, MessageBoxImage.Information); } }
public async Task FetchAsyncOnline() { var orchestrator = new FeedOrchestrator("Name", "Description"); orchestrator.ClearCache(); var feedInfos = new List <FeedInfo> { new FeedInfo { Name = "test1", Url = "https://devblogs.microsoft.com/visualstudio/rss" }, new FeedInfo { Name = "test2", Url = "http://feeds.hanselman.com/ScottHanselman" } }; System.ServiceModel.Syndication.SyndicationFeed feed = await orchestrator.GetFeedAsync(feedInfos, false); Assert.AreEqual(20, feed.Items.Count()); }
public async Task FetchAsyncDuplicatesFromCache() { var orchestrator = new FeedOrchestrator("Name", "Description"); orchestrator.ClearCache(); for (var i = 0; i < 2; i++) { var feedInfos = new List <FeedInfo> { new FeedInfo { Name = "test1", Url = "https://devblogs.microsoft.com/visualstudio/rss" }, new FeedInfo { Name = "test1", Url = "https://devblogs.microsoft.com/visualstudio/rss" }, }; System.ServiceModel.Syndication.SyndicationFeed feed = await orchestrator.GetFeedAsync(feedInfos, false); Assert.AreEqual(10, feed.Items.Count()); } }
protected SyndicationFeed(System.ServiceModel.Syndication.SyndicationFeed source, bool cloneItems) { }