async static Task MainAsync(string[] args) { IList <string> strList = new List <string>(); strList.Add("https://news.google.com/topics/CAAqIggKIhxDQkFTRHdvSkwyMHZNRGxqTjNjd0VnSmxiaWdBUAE?hl=en-US&gl=US&ceid=US%3Aen"); //Google US News strList.Add("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRGx1YlY4U0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //Google World strList.Add("https://news.google.com/publications/CAAqEQgKIgtDQklTQWdnR0tBQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //Google Local strList.Add("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRGx6TVdZU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //Google Business strList.Add("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRGRqTVhZU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //Google Tech strList.Add("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNREpxYW5RU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //Google Entertain strList.Add("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRFp1ZEdvU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //Google Sports strList.Add("https://news.google.com/topics/CAAqJggKIiBDQkFTRWdvSUwyMHZNRFp0Y1RjU0FtVnVHZ0pWVXlnQVAB?hl=en-US&gl=US&ceid=US%3Aen"); //google Science strList.Add("https://news.google.com/topics/CAAqIQgKIhtDQkFTRGdvSUwyMHZNR3QwTlRFU0FtVnVLQUFQAQ?hl=en-US&gl=US&ceid=US%3Aen"); //google health foreach (var NewsURL in strList) { HttpClient client = new HttpClient(); var response = await client.GetAsync(NewsURL.ToString()); var pageContents = await response.Content.ReadAsStringAsync(); HtmlDocument pageDocument = new HtmlDocument(); pageDocument.LoadHtml(pageContents); IEnumerable <HtmlNode> nodes = pageDocument.DocumentNode.SelectNodes("(//article//h3//a)"); foreach (var item in nodes) { if (item.InnerHtml.Contains("Hack") || item.InnerHtml.Contains("Hacking") || item.InnerHtml.Contains("security") || item.InnerHtml.Contains("Hacking") || item.InnerHtml.Contains("Breach") || item.InnerHtml.Contains("AMD") || item.InnerHtml.Contains("nvidia") || item.InnerHtml.Contains("NVIDIA") || item.InnerHtml.Contains("coding")) { Console.WriteLine(item.InnerHtml); } } } }
// Get resource manager //private ResourceManager rm = new ResourceManager("LearningPortalUtilities.Strings", Assembly.GetExecutingAssembly()); protected void Page_Load(object sender, System.EventArgs e) { // ltlPageTitle.Text = GetLocalResourceObject("X").ToString(); ltlLBTitle.Text = GetLocalResourceObject("Title").ToString(); ltlBegin.Text = GetLocalResourceObject("Begin").ToString(); // Resources.Strings.Begin; ltlEnd.Text = GetLocalResourceObject("End").ToString(); // Resources.Strings.End; ltlDescription.Text = GetLocalResourceObject("Description").ToString(); // Resources.Strings.Description; ltlLocation.Text = GetLocalResourceObject("Location").ToString(); //Resources.Strings.Location; ltlCreatedAt.Text = GetLocalResourceObject("CreatedAt").ToString(); //Resources.Strings.CreatedAt; ltlModifiedAt.Text = GetLocalResourceObject("LastModifiedAt").ToString(); //Resources.Strings.LastModifiedAt; //ltlBy1.Text = GetLocalResourceObject ("By").ToString();//Resources.Strings.By; //ltlBy2.Text = GetLocalResourceObject ("By").ToString();//Resources.Strings.By; HtmlTableRow rw; HtmlTableCell cell; string NewsURL; int NewsID; NewsURL = Request.QueryString.GetValues("URL")[0]; // Add the terminating slash if not present if (!NewsURL.EndsWith("/")) { NewsURL += "/"; } NewsID = int.Parse(Request.QueryString.GetValues("ID")[0]); // Open the site, and the default web SPSite mysite = new SPSite(NewsURL); SPWeb myWeb = mysite.OpenWeb(); // Get the view of this list, and from that the reference to the list itself SPView view = myWeb.GetViewFromUrl(NewsURL + "allitems.aspx"); SPList list = myWeb.Lists[view.ParentList.Title]; ltlListName.Text = list.Title; // Get the Item from the list SPListItem myItem = list.GetItemById(NewsID); ltlTitle.Text = myItem["ows_Title"].ToString(); ltlItemTitle.Text = myItem["ows_Title"].ToString(); // Begin (mandatory) ltlItemBegin.Text = ((DateTime)myItem["ows_EventDate"]).ToString(); // End (not mandatory) if (myItem["ows_EndDate"] != null) { ltlItemEnd.Text = ((DateTime)myItem["ows_EndDate"]).ToString(); } else { ltlItemEnd.Text = "--"; } // Description (not mandatory) if (myItem["ows_Description"] != null) { ltlItemDescription.Text = myItem["ows_Description"].ToString(); } else { ltlItemDescription.Text = "--"; } // Location (not mandatory) if (myItem["ows_Location"] != null) { ltlItemLocation.Text = myItem["ows_Location"].ToString(); } else { ltlItemLocation.Text = "--"; } // Created ltlItemCreated.Text = ((DateTime)myItem["ows_Created"]).ToString(); //ltlItemCreatedBy.Text = myItem["ows_Author"].ToString().Split('#')[1]; // Modified ltlItemLastModified.Text = ((DateTime)myItem["ows_Modified"]).ToString(); //ltlItemLastModifiedBy.Text = myItem["ows_Editor"].ToString().Split('#')[1]; try { //Issue #9 - Sometimes the instant messenger icon doesn't appear //myWeb.SiteUsers.GetByID(UserID) is used to get the user object with id = UserID int AuthorID = int.Parse(myItem["ows_Author"].ToString().Split('#')[0].Replace(";", "")); int EditorID = int.Parse(myItem["ows_Editor"].ToString().Split('#')[0].Replace(";", "")); //if (myWeb.SiteUsers.GetByID(AuthorID).Email.Length > 0) // imn0.Attributes.Add("onload", "IMNRC('" + myWeb.SiteUsers.GetByID(AuthorID).Email + "')"); //if (myWeb.SiteUsers.GetByID(EditorID).Email.Length > 0) // imn1.Attributes.Add("onload", "IMNRC('" + myWeb.SiteUsers.GetByID(EditorID).Email + "')"); } catch { } //Clean up myWeb.Close(); mysite.Close(); }