private void GetData(string url) { string readfile = string.Empty; lbl.Text = string.Empty; HtmlWeb web = new HtmlWeb(); HtmlDocument myNode = web.Load(url); // Error part myNode.DocumentNode.Descendants().Where(n => n.Name == "script" && n.Name == "style" && n.Name == "link").ToList().ForEach(n => n.Remove()); myNode.DocumentNode.Descendants().Where(n => n.Name == "href" && n.Name == "img").ToList().ForEach(n => n.Remove()); foreach (var elem in elementHtml) { HtmlNode node = myNode.DocumentNode.SelectSingleNode(".//ul[@class='" + elem + "']"); if (node != null) { readfile = node.InnerText.ToString().Trim(); string[] str = readfile.Split(new string[] { "Add to Cart", "or Add to Wish List", "» Add to Compare" }, StringSplitOptions.RemoveEmptyEntries); foreach (string val in str) { DataRow dr = ProdList.NewRow(); dr["Desc"] = val.ToString().Trim().Replace(" ", ""); ProdList.Rows.Add(dr); SaveData(); //WriteTxt(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)