Click here to Skip to main content
16,021,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried to code for this ... but didn't get any result.. my last attemp with this code, which gives me HTMLNODE.ID and i stored them in a dictonary.

Here is the code...
C#
private void Display(string url)
    {
        try
        {
            Label1.Text = string.Empty;
            HtmlWeb web1 = new HtmlWeb();
            HtmlDocument doc = web1.Load(url.TrimEnd('/'));
            doc.DocumentNode.Descendants().Where(n => n.Name == "script" && n.Name == "style" && n.Name == "link").ToList().ForEach(n => n.Remove());
            foreach (HtmlNode value in doc.DocumentNode.SelectNodes(".//div[@*]"))
            {

                if (value.Id != "")
                {
                    if (!dict.ContainsKey(value.Id))
                    {
                        dict.Add(value.Id, value.Id);
                    }
                }
            }
            if (dict.Count > 0)
            {
                foreach (string str in dict.Values)
                {
                    HtmlNode inNode = doc.DocumentNode.SelectSingleNode("//div[(@*='" + str + "')]");
                    Label1.Text += inNode.InnerText.Trim() + "<html><br/></html>";
                }
            }
        }
        catch (Exception ex)
        { Label1.Text = ex.Message; }
    }



With this code i m getting output but with those output i am also getting some other output too like..
Online Shopping Home » Mobile and Accessories » Landlines Mobile And Accessories Showing 1-24 of 84 Results Sort by: Relevancy Highest Price First Lowest Price First Most Recent First 


need help to remove such text from my output if possible

Thank you
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900