public ActionResult searchResultDetailPage(string id, string search, string type) { using (YemekTarifiEntities db = new YemekTarifiEntities()) { TARIF tarif = null; tarif = db.TARIF.FirstOrDefault(c => c.ID == id); if (tarif != null) { if (type != "tumu" && type != "kategori" && type != "site") { type = "tumu"; } ViewBag.tarif = tarif; ViewBag.type = type; ViewBag.search = search; return(View()); } else { return(RedirectToAction("searchEnginePage", "pages")); } } }
public TARIF extractTarifFromHtml(string rstring, string url) { if (!url.Contains("/yemek-tarifleri/")) { return(null); } var tarif = new TARIF();//new Tarif(); tarif.URL = startUrl + url; tarif.SITE_ADI = siteAdi; htmlDoc.OptionFixNestedTags = true; try { htmlDoc.LoadHtml(rstring); List <HtmlNode> list = htmlDoc.DocumentNode.Descendants().Where(x => x.HasClass("show-page-container")).ToList <HtmlNode>()[0].Descendants("span").ToList <HtmlNode>(); tarif.KATEGORI = toTurkish(list[list.Count - 3].InnerText); var currentTarif = htmlDoc.DocumentNode.Descendants("h1").ToList <HtmlNode>()[0]; tarif.YEMEK_ADI = toTurkish(currentTarif.InnerHtml); tarif.RESIM = currentTarif.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.Descendants("img").ToList <HtmlNode>()[0].Attributes["src"].Value; tarif.MALZEMELER = appendString("", htmlDoc.DocumentNode.SelectNodes("//*[contains(@class,'detay-page-materials-content')]").ToList <HtmlNode>()[0].Descendants("li").ToList <HtmlNode>().Select(x => x.InnerText).ToList <String>()); tarif.HAZIRLANIS = appendString("", htmlDoc.DocumentNode.SelectNodes("//*[contains(@class,'detay-page-preparation-of-content')]").ToList <HtmlNode>()[0].Descendants("li").ToList <HtmlNode>().Select(x => x.InnerText).ToList <String>()); //Console.WriteLine(tarif.ToString()); return(tarif); } catch (Exception ex) { //Console.WriteLine(ex); Console.WriteLine("tarif çıkarılamadı : " + url); return(null); } }