public override void SetUp() { base.SetUp(); this.newsFeeds = new NewsFeeds(this.Session); this.english = new Languages(this.Session).FindBy(M.Language.IsoCode, "en"); this.german = new Languages(this.Session).FindBy(M.Language.IsoCode, "de"); this.dutch = new Languages(this.Session).FindBy(M.Language.IsoCode, "nl"); this.multiLanguages = new List <Language>() { this.english, this.german }; this.newsTopic = new TopicBuilder(this.Session).WithName("News").Build(); this.worldTopic = new TopicBuilder(this.Session).WithName("World").Build(); this.noneExistingTopic = new TopicBuilder(this.Session).WithName("None").Build(); this.topics = new List <Topic> { this.worldTopic, this.newsTopic }; this.RemoveAllNewsFeeds(); this.newsFeed = this.newsFeeds.SetupNewsFeed("http://feeds.bbci.co.uk/news/rss.xml", "BBC Top Stories", this.multiLanguages, this.topics); //_newsGermanFeed = newsFeeds.SetupNewsFeed("http://feeds.bbci.co.uk/world/rss.xml", "BBC Top Stories", multiLanguages, topics); //_newsEnglishFeed = newsFeeds.SetupNewsFeed("http://feeds.bbci.co.uk/news/rss.xml", "BBC Top Stories", multiLanguages, topics); }
public string newsfeedset(NewsFeeds newsfeeds) { try { result = orm.execObject <Result>(newsfeeds, "api.admin_newsfeed_set"); } catch (Exception exp) { errorResult(exp); } return(formattedResult(result)); }
private void Parse() { HtmlNode n = htmlDocument.GetElementbyId("news-main"); //if (n != null) //{ foreach (var node in n.ChildNodes) { if (node.GetType() == typeof(HtmlNode) && node.HasAttributes) { if (node.Attributes["class"].Value == "g-section news sfe-break-bottom-16") { NewsFeed newsFeed = new NewsFeed(); foreach (var feedNode in node.ChildNodes) { if (feedNode.Attributes["class"].Value == "name") { HtmlNode nn = HtmlNode.CreateNode(feedNode.InnerHtml); newsFeed.NewsLink = new Uri(nn.Attributes["href"].Value); newsFeed.Title = nn.InnerText; } else if (feedNode.Attributes["class"].Value == "byline") { HtmlNode nn = HtmlNode.CreateNode(feedNode.InnerHtml); newsFeed.Source = nn.NextSibling.InnerText; } else if (feedNode.Attributes["class"].Value == "g-c") { HtmlNode nn = HtmlNode.CreateNode(feedNode.NextSibling.InnerHtml); newsFeed.Snapshot = nn.InnerText; foreach (var nnn in nn.ChildNodes) { if (nnn.Attributes["class"].Value == "more-rel") { // TODO: really need to handle exceptions here. } } } } NewsFeeds.Add(newsFeed); } } } //} }
public override void SetUp() { base.SetUp(); this.newsFeeds = new NewsFeeds(this.Session); this.english = new Languages(this.Session).FindBy(M.Language.IsoCode, "en"); this.german = new Languages(this.Session).FindBy(M.Language.IsoCode, "de"); this.englishLanguages = new List <Language>() { this.english }; this.multiLanguages = new List <Language>() { this.english, this.german }; }
/// <summary> /// Read news by source /// </summary> /// <param name="providerURL"></param> /// <returns></returns> public NewsFeeds ReadNews(string providerURL) { WebClient wclient = new WebClient(); string newsData = wclient.DownloadString(providerURL); XDocument xml = XDocument.Parse(newsData); var data = new NewsFeeds(); data.NewsFeedList = (from x in xml.Descendants("item") select new News { Title = ((string)x.Element("title")), URL = ((string)x.Element("link")), Description = ((string)x.Element("description")), Date = DateTime.Parse(((string)x.Element("pubDate"))) }).ToList(); return(data); }
/// <summary> /// Return the news /// </summary> /// <param name="source"></param> /// <returns></returns> public NewsFeeds GetNews(string source) { var result = new NewsFeeds(); result.NewsFeedList = new List <News>(); if (string.IsNullOrEmpty(source)) { var sources = GetSources(); foreach (var item in sources) { //var list = ReadNews(item).NewsFeedList; result.NewsFeedList.AddRange(ReadNews(item).NewsFeedList); } } else { result.NewsFeedList.AddRange(ReadNews(source).NewsFeedList); } return(result); }
public ActionResult Index(string providerURL) { WebClient wclient = new WebClient(); string newsData = wclient.DownloadString(providerURL); XDocument xml = XDocument.Parse(newsData); var data = new NewsFeeds(); data.NewsFeedList = (from x in xml.Descendants("item") select new News { Title = ((string)x.Element("title")), URL = ((string)x.Element("link")), Description = ((string)x.Element("description")), Date = DateTime.Parse(((string)x.Element("pubDate"))) }).ToList(); data.NewsFeedURL = ""; ViewBag.RSSFeed = data; ViewBag.URL = providerURL; ViewBag.URLNEWS = ""; return(View(data)); }
static void Main(string[] args) { Console.Title = ""; var userInput = String.Empty; Console.SetWindowSize(80, 30); SystemString(out userInput, "withGreeting"); while (userInput.ToLower() != "exit") { List <News_Source> newsList = new List <News_Source>(); if (!Int32.TryParse(userInput, out int n)) { Console.WriteLine("Error Input"); userInput = Console.ReadLine(); } else { switch (Int32.Parse(userInput)) { case 1: //Insert List <News_Source> insertdata = new List <News_Source>(); RssReader newsMethod = new RssReader(); Console.WriteLine("Please Insert New Feeds URL:"); userInput = Console.ReadLine(); insertdata = newsMethod.getNews(String.Format("{0}", userInput)); NewsFeeds.post(insertdata); break; case 2: //Update NewsFeeds.updateAll(); break; case 3: //Search newsList.Clear(); newsList = NewsFeeds.get(); Console.WriteLine("Choose one news to list.\n(Insert number)"); userInput = Console.ReadLine(); if (Int32.Parse(userInput) <= newsList.Count && userInput != "0") { Console.WriteLine(userInput); NewsFeeds.get(newsList[Int32.Parse(userInput) - 1]); } break; case 4: //Remove newsList.Clear(); newsList = NewsFeeds.get(); Console.WriteLine("Choose one news to delete.\n(Insert number)"); userInput = Console.ReadLine(); NewsFeeds.delete(newsList[Int32.Parse(userInput) - 1]); break; case 5: //Get Feeds URL list NewsFeeds.getFeeds(); break; case 6: //Auto Update and Send via Telegram bot Timer t = new Timer(TimerCallback, null, 0, 60 * 1000); break; default: break; } ; SystemString(out userInput, "withoutGreeting"); } } ; }