private int Consume5Pots() { string url = "5Pots"; string type = "League of Legends"; string link = "http://5pots.com/"; HttpDownloader httpDownloader; List <News> RssNews = new List <News>(); News _new = new News(); httpDownloader = new HttpDownloader(link, "", ""); string html = httpDownloader.GetPage(); html = Regex.Replace(html, @"\t", ""); html = Regex.Replace(html, @"\n", ""); string[] aux = html.Split(new string[] { "full" }, StringSplitOptions.None); for (int i = 3; i < aux.Length; i++) { string[] subAux = aux[i].Split('>'); _new.Url = url; _new.Source = url; _new.NewsType = type; _new.Link = subAux[18].Split('"')[1]; _new.Title = subAux[6].Split('<')[0]; _new.Img = subAux[19].Split('"')[5]; _new.Date = DateTime.Parse(subAux[11].Split(' ')[2]); if (subAux[24] != "<strong") { _new.ShortDesc = subAux[24].Split('<')[0]; _new.Text = "<p>Fala meu povo Mixturados, mais uma notícia adicionada para vocês, retirada do RSS do site " + url + "</p><p>" + subAux[26].Split('<')[0] + "</p><p>Para continuar lendo esta super matéria, basta clicar no link: <a href='" + _new.Link + "'>" + _new.Link + "</a></p>"; } else { _new.ShortDesc = subAux[29].Split('<')[0]; _new.Text = "<p>Fala meu povo Mixturados, mais uma notícia adicionada para vocês, retirada do RSS do site " + url + "</p><p>" + subAux[32].Split('<')[0] + "</p><p>Para continuar lendo esta super matéria, basta clicar no link: <a href='" + _new.Link + "'>" + _new.Link + "</a></p>"; } _new.Author = "MixBot"; _new.IsPublished = true; RssNews.Add(_new); _new = new News(); } _new = new News(); return(CreateNews(RssNews)); }
private int ConsumeSiteHard(string url, string type, string site) { HttpDownloader httpDownloader; List <News> RssNews = new List <News>(); News _new = new News(); WebClient webClient = new WebClient(); webClient.Headers.Add("user-agent", "MyRSSReader/1.0"); XmlReader reader = XmlReader.Create(webClient.OpenRead(site)); var xmlDocument = new XmlDocument(); //xmlDocument.Load(reader); SyndicationFeed feed = SyndicationFeed.Load(reader); reader.Close(); foreach (SyndicationItem item in feed.Items) { String subject = item.Title.Text; String summary = item.Summary.Text; string link = item.Links[0].Uri.AbsoluteUri; httpDownloader = new HttpDownloader(link, "", ""); string html = httpDownloader.GetPage(); //var html = new System.Net.WebClient().DownloadString(link); _new.Img = FetchLinksFromSource(html, url); _new.Url = url; _new.Link = item.Links[0].Uri.AbsoluteUri; _new.Text = FormatText(item.Summary.Text, url, _new.Link); _new.ShortDesc = item.Title.Text; _new.NewsType = type; _new.Date = DateTime.Parse(item.PublishDate.ToString()); _new.Author = "MixBot"; _new.Title = item.Title.Text; _new.Source = url; _new.IsPublished = true; RssNews.Add(_new); _new = new News(); } return(CreateNews(RssNews)); }
private int ConsumeCoja(string url, string type, string site) { HttpDownloader httpDownloader; List <News> RssNews = new List <News>(); News _news = new News(); var webClient = new WebClient(); httpDownloader = new HttpDownloader(site, "", ""); string rss = httpDownloader.GetPage(); XDocument document = XDocument.Parse(rss); XNamespace nsContent = "http://purl.org/rss/1.0/modules/content/"; XNamespace dcM = "http://search.yahoo.com/mrss/"; foreach (var descendant in document.Descendants("item")) { _news.Text = descendant.Element(nsContent + "encoded").Value; _news.ShortDesc = descendant.Element("description").Value; _news.Date = DateTime.Parse(descendant.Element("pubDate").Value); _news.Title = descendant.Element("title").Value; _news.Img = descendant.Element(dcM + "thumbnail").Attribute("url").Value; _news.Author = "MixBot"; _news.Source = url; _news.Url = url; _news.NewsType = type; _news.Link = descendant.Element("link").Value; _news.IsPublished = false; RssNews.Add(_news); _news = new News(); } return(CreateNews(RssNews)); }
private int ConsumeRSS(string url, string type, string site) { HttpDownloader httpDownloader; List <News> RssNews = new List <News>(); News _news = new News(); var webClient = new WebClient(); httpDownloader = new HttpDownloader(site, "", ""); string rss = httpDownloader.GetPage(); XDocument document = XDocument.Parse(rss); XNamespace nsContent = "http://purl.org/rss/1.0/modules/content/"; XNamespace dcM = "http://search.yahoo.com/mrss/"; foreach (var descendant in document.Descendants("item")) { if (descendant.Element(nsContent + "encoded") != null) { _news.Text = ConvertEncoding(descendant.Element(nsContent + "encoded").Value); } else { _news.Text = ConvertEncoding(descendant.Element("description").Value); } _news.Text = FormatText(_news.Text, url, descendant.Element("link").Value); _news.ShortDesc = StripTagsRegex(descendant.Element("description").Value); _news.Date = DateTime.Parse(descendant.Element("pubDate").Value); _news.Title = descendant.Element("title").Value; if (descendant.Element(dcM + "thumbnail") == null) { if (descendant.Element("enclosure") == null) { httpDownloader = new HttpDownloader(descendant.Element("link").Value, "", ""); string html = httpDownloader.GetPage(); _news.Img = FetchLinksFromSource(html, url); } else { _news.Img = descendant.Element("enclosure").Attribute("url").Value; } } else { _news.Img = descendant.Element(dcM + "thumbnail").Attribute("url").Value; } _news.Author = "MixBot"; _news.Source = url; _news.Url = url; _news.NewsType = DefineType(_news.Text, _news.Title); _news.Link = descendant.Element("link").Value; _news.IsPublished = true; RssNews.Add(_news); _news = new News(); } foreach (var descendant in document.Descendants("entry")) { if (descendant.Element(nsContent + "encoded") != null) { _news.Text = descendant.Element(nsContent + "encoded").Value; } else { _news.Text = descendant.Element("description").Value; } _news.Text = FormatText(_news.Text, url, descendant.Element("link").Value); _news.ShortDesc = StripTagsRegex(descendant.Element("description").Value); _news.Date = DateTime.Parse(descendant.Element("pubDate").Value); _news.Title = descendant.Element("title").Value; if (descendant.Element(dcM + "thumbnail") == null) { if (descendant.Element("enclosure") == null) { httpDownloader = new HttpDownloader(descendant.Element("link").Value, "", ""); string html = httpDownloader.GetPage(); _news.Img = FetchLinksFromSource(html, url); } else { _news.Img = descendant.Element("enclosure").Attribute("url").Value; } } else { _news.Img = descendant.Element(dcM + "thumbnail").Attribute("url").Value; } _news.Author = "MixBot"; _news.Source = url; _news.Url = url; _news.NewsType = DefineType(_news.Text, _news.Title); _news.Link = descendant.Element("link").Value; _news.IsPublished = true; RssNews.Add(_news); _news = new News(); } return(CreateNews(RssNews)); }