static void ScrapeFoodStore(SlackClient client, List <Resturante> resturangList, int day, bool send) { var vecka = new List <Veckodag>(); Resturante FoodStore = new Resturante("Food Store"); if (send == true) { client.PostMessage(username: "******", text: $"{vecka[day].Name} Alternativ 1 {vecka[day].FoodAlternativ[0]}", channel: "#foodchannel"); client.PostMessage(username: "******", text: $"{vecka[day].Name} Alternativ 2 {vecka[day].FoodAlternativ[1]}", channel: "#foodchannel"); } }
static void ScrapeKrubbstugan(SlackClient client, List <Resturante> resturangList, int day, bool send) { HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb(); HtmlAgilityPack.HtmlDocument doc = web.Load("http://www.krubbstugan.se/2.html"); Resturante krubbstugan = new Resturante("Krubbstugan"); resturangList.Add(krubbstugan); string id = "t3"; var matsedel = doc.GetElementbyId(id); string food = matsedel.InnerText; var vecka = new List <Veckodag>(); var innerScrapedText = new List <string>(); //Get the whole meny innerScrapedText.AddRange(food.Split("\n")); //Remove the first to lines, they are irrilevant innerScrapedText.RemoveAt(0); innerScrapedText.RemoveAt(0); //Gather the names of the week days. for (int i = 0; i < innerScrapedText.Count; i += 3) { Veckodag veckodag = new Veckodag(); innerScrapedText[i] = innerScrapedText[i].Replace(" ", " "); innerScrapedText[i] = innerScrapedText[i].Replace(" ", ""); veckodag.Name = innerScrapedText[i]; vecka.Add(veckodag); } int y = 0; int x = 1; //Gather the food of each days for (int i = 0; i < vecka.Count + 2; i++) { innerScrapedText[x] = innerScrapedText[x].Replace(" ", " "); innerScrapedText[x] = innerScrapedText[x].Replace("&", " "); if (i == 0 || i == 3 || i == 6 || i == 9 || i == 12) { continue; } vecka[y].FoodAlternativ.Add(innerScrapedText[x]); x++; vecka[y].FoodAlternativ.Add(innerScrapedText[x]); x += 2; y++; } //Get the right day of the week if (send == true) { client.PostMessage(username: "******", text: $"{vecka[day].Name} Alternativ 1 {vecka[day].FoodAlternativ[0]}", channel: "#foodchannel"); client.PostMessage(username: "******", text: $"{vecka[day].Name} Alternativ 2 {vecka[day].FoodAlternativ[1]}", channel: "#foodchannel"); } Console.WriteLine($"{vecka[day].Name} Alternativ 1 {vecka[day].FoodAlternativ[0]}"); Console.WriteLine($"{vecka[day].Name} Alternativ 2 {vecka[day].FoodAlternativ[1]}"); }