0

I wanted to create a function on C# console application that able to click on html tag and store data from link, firstofall I traverse html with htmlagilitypack(Xpath query) and find all of the tag,that name is "Contact details". on that page there are 20 of "Contact Details" link,I Want Click on "Contact Details" one by one and store data on database and return to another "Contact Details" link. pagelink: http://www.alibaba.com/corporations/iranian/1.html after that when there isnt any "Contact Details" for clicked I want to click to another link like: http://www.alibaba.com/corporations/iranian/2.html

a part of program code for find "Contact Details" Please help me.

 public static void traverseAndAppend()
    {


        string url = "http://www.alibaba.com/corporations/iranian/1.html";
        HtmlWeb web = new HtmlWeb();
        HtmlDocument doc = web.Load(url);
        string contactDetails = "//div[@class='company']/a[@class='cd']";

        foreach (HtmlNode node doc.DocumentNode.SelectNodes(contactDetails))
        {

            Console.WriteLine(node.InnerText.Trim());


        }



    }
howin
  • 1
  • So, do you have a question? – JLRishe Mar 27 '15 at 11:57
  • @JLRishe how to Create a function that able to click on Each "Contact Details" tag ,That is my question. – howin Mar 27 '15 at 13:08
  • I don't think you can click with htmlagility. But in this case is "Click the button" the same as "navigate to a new page". So, you can just foreach(){ doc = web.load(new_Url); Do some logic} – Helmer Mar 30 '15 at 14:59

0 Answers0