void import(string pathl) { //MessageBox.Show(path + "/" + pathl); StreamReader sr = new StreamReader(path + "/" + pathl); string text = sr.ReadToEnd(); sr.Close(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(text); HtmlNodeCollection node = doc.DocumentNode.SelectNodes("//a[@href]"); //Here, you can also do something like (".//span[@id='point_total' class='tooltip' jQuery16207621750175125325='23' oldtitle='Note: If the number is black, your points are actually a little bit negative. Don't worry, this just means you need to start subbing again.']"); to select specific spans, etc... HtmlNode title = doc.DocumentNode.SelectSingleNode("//h1"); HtmlNode desc = doc.DocumentNode.SelectSingleNode("//h2"); HtmlNode img = doc.DocumentNode.SelectSingleNode("//img[@src]"); textBox3.Text = title.InnerHtml; textBox4.Text = desc.InnerHtml; textBox11.Text = img.Attributes.ElementAt(0).Value; textBox6.Text = node.ElementAt(0).Attributes.ElementAt(1).Value.Substring(0, node.ElementAt(0).Attributes.ElementAt(1).Value.Length - 5);; textBox5.Text = node.ElementAt(0).InnerText; textBox9.Text = node.ElementAt(1).Attributes.ElementAt(1).Value.Substring(0, node.ElementAt(1).Attributes.ElementAt(1).Value.Length - 5);; textBox7.Text = node.ElementAt(1).InnerText; textBox10.Text = node.ElementAt(2).Attributes.ElementAt(1).Value.Substring(0, node.ElementAt(2).Attributes.ElementAt(1).Value.Length - 5); textBox8.Text = node.ElementAt(2).InnerText; textBox12.Text = node.ElementAt(3).Attributes.ElementAt(1).Value.Substring(0, node.ElementAt(3).Attributes.ElementAt(1).Value.Length - 5); textBox13.Text = node.ElementAt(3).InnerText; textBox15.Text = node.ElementAt(4).Attributes.ElementAt(1).Value.Substring(0, node.ElementAt(4).Attributes.ElementAt(1).Value.Length - 5); textBox14.Text = node.ElementAt(4).InnerText; textBox1.Text = pathl.Substring(0, pathl.Length - 5); //MessageBox.Show(value); }
public override Dictionary <Person, string> GetImperative(string rawData) { string tenseKeyword; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(rawData); if (doc.ParseErrors != null && doc.ParseErrors.Count() > 0) { // Handle any parse errors as required } List <string> tenseMatches = new List <string>(); if (doc.DocumentNode != null) { HtmlNodeCollection words = doc.DocumentNode.SelectNodes(@"//h3[normalize-space(text()) = 'Imperative']/../table/tbody/tr[1]/td[position()>2]"); if (words.Count == 5) { tenseMatches.Add("-"); } for (int i = 0; i < words.Count; i++) { tenseMatches.Add(words.ElementAt(i).InnerText); } } var result = ExtractConjugationFromMatches(tenseMatches); return(result); }
public override IEnumerable <string> FindMatchesPerTense(string page, string tenseKeyword) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(page); if (doc.ParseErrors != null && doc.ParseErrors.Count() > 0) { // Handle any parse errors as required } List <string> tenseMatches = new List <string>(); if (doc.DocumentNode != null) { //HtmlNode preteriteNode = doc.DocumentNode.SelectSingleNode(@"html/body/div[2]/div[2]/div[2]/div[4]"); //string preterite = preteriteNode.SelectSingleNode("//span").InnerText; //HtmlNode conjugationTable = doc.DocumentNode.SelectSingleNode(@"html/body/div[2]/div[2]/div[2]/div[6]/table"); HtmlNodeCollection words = doc.DocumentNode.SelectNodes(@"//div[@class='_1kOv9vAh']"); ////HtmlNodeCollection words = doc.DocumentNode.SelectNodes(@"//td[contains(@class,'vtable-word')]"); int tenseIndex = GetTenseIndex(tenseKeyword); for (int i = 0; i < 6; i++) { //TODO i * 5 needs to be configurable to account for the Imperative and few other things (or extract it in another method) tenseMatches.Add(words.ElementAt(i * 5 + tenseIndex).InnerText); } } return(tenseMatches); }
public override string GetGerund(string rawData) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(rawData); if (doc.ParseErrors != null && doc.ParseErrors.Count() > 0) { // Handle any parse errors as required } List <string> tenseMatches = new List <string>(); if (doc.DocumentNode == null) { return(string.Empty); } HtmlNodeCollection words = doc.DocumentNode.SelectNodes(@"((//h3[contains(text(),'Gerundio')])[2]/../div/div[@class='conj-result'])"); // Regex rxTense = new Regex(@"<table>((?!table).)*(Gerundio)((?!table).)*</table>"); //Regex rxGerunds = new Regex(@"<tr[^>]*>\s*<td[^>]*>([\w\s]+)</td>\s*</tr>"); //var tenseMatch = rxTense.Match(rawData); //Regex rxGerunds = new Regex(@"<h5 [^>]*>(Gerundio)</h5>(<span [^>]*>([\w/]*)</span>\s*([\s\w]*)(<br>)*)*"); //MatchCollection matchesGerund = rxGerunds.Matches(tenseMatch.Captures[0].Value); if (words.Count == 0) { return(string.Empty); } return(words.ElementAt(0).InnerText); }
////public Dictionary<Person, string> ExtractConjugationFromMatches(IEnumerable<string> matchCollection) ////{ //// Dictionary<Person, string> conjugation = new Dictionary<Person, string>(); //// if (matchCollection.Count() < 6) //// return conjugation; //// for (int i = 0; i < 6; i++) //// { //// string currentConjugation = matchCollection.ElementAt(i).Trim(); //// if (Regex.IsMatch(currentConjugation, @"\w+")) //// { //// conjugation.Add((Person)i, currentConjugation); //// } //// } //// return conjugation; ////} public override IEnumerable <string> FindMatchesPerTense(string page, string tenseKeyword) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(page); if (doc.ParseErrors != null && doc.ParseErrors.Count() > 0 || doc.DocumentNode == null) { throw new FormatException(string.Format("Could not parse tense '{0}'", tenseKeyword)); // Handle any parse errors as required } List <string> tenseMatches = new List <string>(); //HtmlNode preteriteNode = doc.DocumentNode.SelectSingleNode(@"html/body/div[2]/div[2]/div[2]/div[4]"); //string preterite = preteriteNode.SelectSingleNode("//span").InnerText; //HtmlNode conjugationTable = doc.DocumentNode.SelectSingleNode(@"html/body/div[2]/div[2]/div[2]/div[6]/table"); HtmlNodeCollection words = doc.DocumentNode.SelectNodes(string.Format(@"((//h3[contains(text(),'{0}')])[1]/../div/div[@class='conj-result'])", tenseKeyword)); HtmlNodeCollection words1 = doc.DocumentNode.SelectNodes(string.Format(@"((//h3[contains(text(),'{0}')])[1]/../div/div[@class='conj-result'])", tenseKeyword)); int tenseIndex = 0;// GetTenseIndex(GetKeyword(Tense.Imperative)); for (int i = 0; i < 6; i++) { //TODO i * 5 needs to be configurable to account for the Imperative and few other things (or extract it in another method) tenseMatches.Add(words.ElementAt(i + tenseIndex).InnerText); } //Regex rxTense = new Regex(string.Format(@"<table>((?!table).)*({0})((?!table).)*</table>", tenseKeyword)); //Regex rxRow = new Regex(@"<tr[^>]*><td[^>]*>([\w/]+)</td>\s*<td[^>]*>([\w\s]+)</td>\s*</tr>"); //Match tenseMatch = rxTense.Match(page); //return rxRow.Matches(tenseMatch.Value).Cast<Match>(); return(tenseMatches); }
private void ProcessResult(SquashContext context, Tournament tournament, HtmlNodeCollection results, int position) { var player = GetPlayer(context, players.ElementAt(position - 1).Name); for (int i = 2 + position; i < players.Count + 2; i++) { var player2 = GetPlayer(context, players.ElementAt(i - 2).Name); var result = results.ElementAt(i).InnerHtml.Trim().Split(" "); AddResults(context, player, player2, result, tournament); } double rating; if (double.TryParse(results.Last().InnerText.Trim().Replace(" ", ""), out rating)) { player.TournamentResults.Add(new PlayerTournamentResult { Position = position, Points = rating, Tournament = tournament }); } else { player.TournamentResults.Add(new PlayerTournamentResult { Position = position, Points = null, Tournament = tournament }); } context.SaveChanges(); }
public List <PatentFilingRecord> getFilingsInDocument(HtmlDocument htmlDocument, List <PatentFilingRecord> patents) { HtmlNodeCollection tables = htmlDocument.DocumentNode.SelectNodes("//table"); string filingYear = tables.ElementAt(4).SelectSingleNode("thead").SelectSingleNode("tr").SelectSingleNode("th[3]").InnerText; HtmlNode tableBody = tables.ElementAt(4).SelectSingleNode("tbody"); HtmlNodeCollection rows = tableBody.SelectNodes("tr"); foreach (var row in rows) { PatentFilingRecord record = new PatentFilingRecord(); record.PatentFilingYear = filingYear; HtmlDocument rowDoc = new HtmlDocument(); rowDoc.LoadHtml(row.InnerHtml); var rowQuery = from data in rowDoc.DocumentNode.SelectNodes("//th").Cast <HtmlNode>() select new { dataText = data.InnerText }; int i = 0; foreach (var dataItem in rowQuery) { if (i == 0) { record.PatentFilerName = dataItem.dataText.Trim(); } i++; } rowQuery = from data in rowDoc.DocumentNode.SelectNodes("//td").Cast <HtmlNode>() select new { dataText = data.InnerText }; int j = 0; foreach (var dataItem in rowQuery) { if (j == 0) { record.PatentFilingsInYear = Int32.Parse(dataItem.dataText.Trim()); } j++; } patents.Add(record); } return(patents); }
/* Child nodes of parentNode from startInd to endInd are part of the address */ public static void ParseDeliveryAddress(HtmlNodeCollection parentNode, int startInd, int endInd, Order order) { string address = ""; for (int i = startInd; i <= endInd; i++) { string addressPart = parentNode.ElementAt(i).InnerHtml; string actual1 = Regex.Replace(addressPart, @"\t|\n|\r", ""); string actual2 = Regex.Replace(actual1, @"\s+", " "); address = address + actual2 + ","; } order.DeliverAddress = address; }
/// <summary> /// Taks the html element and find the pr.person for a recepie /// </summary> /// <param name="_PerPerson">htmlnode containing perperson</param> /// <returns>returns a float</returns> public float CleanUpPerPerson(HtmlNodeCollection _PerPerson) { if (_PerPerson != null) { String PerPerson = _PerPerson.ElementAt <HtmlNode>(0).InnerText; String cleanUp = ""; float numb; String[] characters = PerPerson.Split(' ', '&', '-'); foreach (String c in characters) { if (float.TryParse(c, out numb)) { return(numb); } } return(float.Parse(cleanUp)); } else { return(4); //4 because all the unreadable recepies by default is 4 on the website } }
public override Dictionary <Person, string> GetImperative(string rawData) { string tenseKeyword; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(rawData); if (doc.ParseErrors != null && doc.ParseErrors.Count() > 0) { // Handle any parse errors as required } List <string> tenseMatches = new List <string>(); if (doc.DocumentNode != null) { //HtmlNode preteriteNode = doc.DocumentNode.SelectSingleNode(@"html/body/div[2]/div[2]/div[2]/div[4]"); //string preterite = preteriteNode.SelectSingleNode("//span").InnerText; //HtmlNode conjugationTable = doc.DocumentNode.SelectSingleNode(@"html/body/div[2]/div[2]/div[2]/div[6]/table"); HtmlNodeCollection words = doc.DocumentNode.SelectNodes(@"((//h3[contains(text(),'Imperativo')])[2]/../div/div[@class='conj-result'])"); HtmlNodeCollection words1 = doc.DocumentNode.SelectNodes(@"//b"); int tenseIndex = 0;// GetTenseIndex(GetKeyword(Tense.Imperative)); for (int i = 0; i < 5; i++) { //TODO i * 5 needs to be configurable to account for the Imperative and few other things (or extract it in another method) tenseMatches.Add(words.ElementAt(i + tenseIndex).InnerText); } } tenseMatches.Insert(0, "a"); var result = ExtractConjugationFromMatches(tenseMatches); result.Remove(Person.FirstSingle); return(result); }
/// <summary> /// A webcrawler specefictly made to crawl the web site https://www.dk-kogebogen.dk/, i findes the diffrent elements of a recepie page, /// such as name of the recipie, ingredients and the desribtion of the dish. /// It will also do some prossecing on each found element to clean them up and make them easier to workd with. /// </summary> /// <param name="start_page">The starting recepie on the website</param> /// <param name="Last_page">The last recepie on the web site it should check</param> /// <param name="dc">The database that should get the finished recipies loaded into</param> /// <returns>It just returns a task as everything is inputed directly into the database while it runs</returns> public async Task GetRecipes(int start_page, int Last_page, DatabaseConnect dc) { AssistingClasses functionality = new AssistingClasses(); for (int i = start_page; i <= Last_page; i++) //loop that goes from the first page to the last page { String url = ("https://www.dk-kogebogen.dk/opskrifter/" + i + "/"); HttpClient HttpClient = new HttpClient(); string html = await HttpClient.GetStringAsync(url); HtmlDocument htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); bool fatalError = false; List <Ingredient> IngriedisensList = new List <Ingredient>(); HtmlNodeCollection ingredienser = htmlDocument.DocumentNode.SelectNodes("//span[@class][@itemprop='recipeIngredient']"); HtmlNodeCollection PerPerson = htmlDocument.DocumentNode.SelectNodes("//span[@itemprop='recipeYield']"); HtmlNodeCollection Beskrivels = htmlDocument.DocumentNode.SelectNodes("//div[@itemprop]"); HtmlNodeCollection name = htmlDocument.DocumentNode.SelectNodes("//center"); Console.WriteLine(i); if (!CheckIfPageFound(name, Beskrivels, ingredienser)) { Console.WriteLine("Cannot find recipie continues...."); } else { var response = HttpClient.GetAsync(url).Result; if (response.StatusCode == System.Net.HttpStatusCode.OK) { foreach (var ind in ingredienser) { if (!ind.InnerText.Contains(':')) { Ingredient ingredient = CreateIngriedient(ind.InnerText, out fatalError, dc, functionality); if (!ingredient._ingredientName.Equals("none")) { IngriedisensList.Add(ingredient); } } if (fatalError) { break; } } if (!fatalError) { Recipe recipe = new Recipe(i, name.ElementAt <HtmlNode>(0).InnerText, Beskrivels.ElementAt <HtmlNode>(0).InnerText, IngriedisensList, functionality.getCleanFunc().CleanUpPerPerson(PerPerson)); await dc.Recipe.AddList(recipe); //recipeImages.AssingItemImage(new RecepieProductHelper(recipe), "bing"); } else { Console.WriteLine("Recipie determined false.."); } } else { Console.WriteLine("Connection failed"); } } } Console.WriteLine("Procces finished"); }
public NodeSingle GetElementByIndex(int index) { var singleNode = _nodesGroup.ElementAt(index); return(new NodeSingle(singleNode)); }
/* Extracts the order from an grubhub html file and returns an Order object */ public Order ParseOrder(string html, DateTime dateTime, string messageId) { Order order = new Order(); order.Service = "GrubHub"; order.TimeReceived = dateTime; order.MessageId = messageId; var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(html); //We begin setting the possible locations of the relevant information, and then choose which one depending on the format on the html doc string metaInfoLoc1 = "//body/table/tbody/tr/td/table/tbody/tr/td/table[3]/tbody/tr/th[2]/table/tbody/tr/th/div/div[2]/div/div"; string metaInfoLoc2 = "//body/table/tbody/tr/td/table/tbody/tr/td/table[4]/tbody/tr/th[2]/table/tbody/tr/th/div/div/div/div"; string metaInfoLoc3 = "//body/table/tbody/tr/td/table/tbody/tr/td/table[5]/tbody/tr/th[2]/table/tbody/tr/th/div/div/div/div"; string metaInfoBaseLoc1 = "//body/table/tbody/tr/td/table/tbody/tr/td/table[3]"; string metaInfoBaseLoc2 = "//body/table/tbody/tr/td/table/tbody/tr/td/table[4]"; string metaInfoBaseLoc3 = "//body/table/tbody/tr/td/table/tbody/tr/td/table[5]"; string delivMethodLoc1 = @"/tbody/tr/th/table/tbody/tr/th/div/div[2]/div/span/span"; string delivMethodLoc2 = @"/tbody/tr/th/table/tbody/tr/th/div/div/div/span/span"; string delivMethodLoc3 = @"/tbody/tr/th/table/tbody/tr/th/div/div/div/span/span"; string pickUpTimeLoc1 = @"/tbody/tr/th/table/tbody/tr/th/div/div[2]/div[2]/span"; string pickUpTimeLoc2 = @"/tbody/tr/th/table/tbody/tr/th/div/div/div[2]/span"; string pickUpTimeLoc3 = @"/tbody/tr/th/table/tbody/tr/th/div/div/div[2]/span"; HtmlNodeCollection metaInfoNodes = null; HtmlNode deliveryMethodNode = null; HtmlNode pickupTimeNode = null; //If this is not null, the order is in standard format if (htmlDoc.DocumentNode.SelectNodes(metaInfoLoc1) != null) { //Debug.WriteLine("Using Standard format"); metaInfoNodes = htmlDoc.DocumentNode.SelectNodes(metaInfoLoc1); deliveryMethodNode = htmlDoc.DocumentNode.SelectSingleNode(metaInfoBaseLoc1 + delivMethodLoc1); pickupTimeNode = htmlDoc.DocumentNode.SelectSingleNode(metaInfoBaseLoc1 + pickUpTimeLoc1); } //Otherwise the previous loc is null and there's an extra <table> "SCHEDULED ORDER" before the pickup/delivery <table> //so we use location 2 else if (htmlDoc.DocumentNode.SelectNodes(metaInfoLoc2) != null) { //Debug.WriteLine("Using Scheduled Order format"); metaInfoNodes = htmlDoc.DocumentNode.SelectNodes(metaInfoLoc2); deliveryMethodNode = htmlDoc.DocumentNode.SelectSingleNode(metaInfoBaseLoc2 + delivMethodLoc2); pickupTimeNode = htmlDoc.DocumentNode.SelectSingleNode(metaInfoBaseLoc2 + pickUpTimeLoc2); } //Otherwise the previous loc is null and there's also an extra <table> "ORDER ADJUSTMENT" before the relevant <table> //so we use location 3 else if (htmlDoc.DocumentNode.SelectNodes(metaInfoLoc3) != null) { //Debug.WriteLine("Using Adjusted Order format"); metaInfoNodes = htmlDoc.DocumentNode.SelectNodes(metaInfoLoc3); deliveryMethodNode = htmlDoc.DocumentNode.SelectSingleNode(metaInfoBaseLoc3 + delivMethodLoc3); pickupTimeNode = htmlDoc.DocumentNode.SelectSingleNode(metaInfoBaseLoc3 + pickUpTimeLoc3); } //If location 3 is still null, then the format is not recognized else { //Debug.WriteLine("Cannot parse order - format not recognized"); return(null); } var orderNumberNode = htmlDoc.DocumentNode.SelectSingleNode("//body/table/tbody/tr/td/table/tbody/tr/td/table[2]/tbody/tr/th/table/tbody/tr/th/div/div[4]/span[2]"); ParseOrderNumber(orderNumberNode, order); ParsePickUpTime(pickupTimeNode, order); int metaDivCount = metaInfoNodes.Count; //the # of <div> elems int nonItemCount = 5; //the last 5 <tr>'s of the <tbody> is meta information int lastAddressIndex = metaDivCount - 3; //We need to know whether it's DELIVERY or PICKUP because there's a difference in the html structure if (deliveryMethodNode.InnerHtml.Trim() == "DELIVERY") { nonItemCount = 6; } else { order.DeliveryMethod = "Pickup"; } var pickupByNameNode = metaInfoNodes.ElementAt(1); ParsePickupName(pickupByNameNode, order); ParseContactNumber(metaInfoNodes.ElementAt(metaDivCount - 1), order); var orderContentNodes = htmlDoc.DocumentNode.SelectNodes("//td[@class='orderSummary__data']"); //order.UniqueItemCount = orderContentNodes.Count - nonItemCount; //Loops through all the td nodes with class = "orderSummary__data" //Parses itemName from td's with inner structure <div> //Parses addOns from td's with inner structure <div> <ul> //Does nothing for td's with no css child nodes //Stops parsing when hitting the td with inner node <span>, or when there are no more tdNodes to scan bool parsedItemName = false; Item item = null; for (int i = 0; i < orderContentNodes.Count; i++) { var tdNode = orderContentNodes[i]; string spanNodePath = tdNode.XPath + "/span"; var spanNode = tdNode.SelectSingleNode(spanNodePath); if (spanNode != null) { //Debug.WriteLine("Hit td with <span> - breaking"); break; } var divNode = tdNode.Element("div"); if (divNode == null) { //Debug.WriteLine("No childs nodes - no addons"); continue; } if (divNode.Element("ul") != null) { //Debug.WriteLine("contains addOns"); ParseAddOns(divNode.Element("ul"), item); } else { //Since Special Instructions and ItemNames have the same html strucuture, //we need manually check the innerHTML to decide which it is if (divNode.InnerHtml.Trim().StartsWith("Instructions")) { ParseSpecialInstruction(divNode, item); } else { //Debug.WriteLine("is an itemName"); if (item != null) { order.ItemList.Add(item); //add the previous item if it's not null, then handle the new item } item = new Item(); ParseItemName(divNode, item); ParseQuantity(tdNode, item); ParseItemType(divNode, item); } } //SetItemCount(i + 1, order.UniqueItemCount, item); } order.ItemList.Add(item); //add the last item since it won't be added without a next item DoorDashParser.SetDrinkAndSnackCount(order); DoorDashParser.SetOrderSize(order); //Need to move function to be general ParseConfirmURL(order, htmlDoc); return(order); }
//MAKALE SERVİS public ActionResult Questions() { Uri url = new Uri("https://www.wired.com/most-recent/"); WebClient client = new WebClient(); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string html = client.DownloadString(url); HtmlAgilityPack.HtmlDocument dokuman = new HtmlAgilityPack.HtmlDocument(); dokuman.LoadHtml(html); HtmlNodeCollection basliklar = dokuman.DocumentNode.SelectNodes("//li[@class='archive-item-component']"); String[] linkler = new string[5]; int i = 0; foreach (var baslik in basliklar) { if (i == 5) { break; } //string ReplaceString = baslik.OuterHtml.Replace("\"", "'"); int LinkBasla = baslik.OuterHtml.IndexOf("href="); int LinkBitir = baslik.OuterHtml.IndexOf("<div class=\"archive-item-component__img\">"); string link = baslik.OuterHtml.Substring(LinkBasla + 7, LinkBitir - LinkBasla - 10); //link = link.Substring(0, link.Length - 34); linkler[i] = link; i++; } List <QuestionsModel> questList = new List <DataModel.QuestionsModel>(); for (int j = 0; j < 5; j++) { Uri NewURL = new Uri("https://www.wired.com/" + linkler[j]); WebClient newClient = new WebClient(); ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string NewHtml = newClient.DownloadString(NewURL); HtmlAgilityPack.HtmlDocument NewDokuman = new HtmlAgilityPack.HtmlDocument(); NewDokuman.LoadHtml(NewHtml); HtmlNodeCollection NewBaslik = NewDokuman.DocumentNode.SelectNodes("//h1[@id='articleTitleFull']"); HtmlNodeCollection NewDescription = NewDokuman.DocumentNode.SelectNodes("//p"); /* * ' --> ' * & --> & */ if (NewBaslik != null) { QuestionsModel qq = new DataModel.QuestionsModel(); qq.Topic = NewBaslik.ElementAt(0).InnerHtml.Replace("'", "'"); qq.Topic = qq.Topic.Replace("&", "&"); qq.Ask = NewDescription.ElementAt(0).InnerText; questList.Add(qq); } if (NewBaslik == null) { NewBaslik = NewDokuman.DocumentNode.SelectNodes("//h1[@class='content-header__row content-header__hed']"); if (NewBaslik != null) { QuestionsModel qq = new DataModel.QuestionsModel(); qq.Topic = NewBaslik.ElementAt(0).InnerHtml.Replace("'", "'"); qq.Topic = qq.Topic.Replace("&", "&"); qq.Ask = NewDescription.ElementAt(0).InnerText; questList.Add(qq); } } } ViewData["Liste"] = questList; HttpContext.Session.SetString("Liste", JsonConvert.SerializeObject(questList)); return(View(questList)); }