例如输入:http://www.alibaba.com/trade/search?fsb=y&IndexArea=company_en&CatId=&SearchText=beijing这个页面,这个页面上有很多旺旺,如何实现自动将这个页面上的旺旺都点开。c#

解决方案 »

  1.   


    // 先添加引用COM组件MSHTML(Microsoft HTML Object Library)和SHDocVw(Microsoft Internet Controls)
    using System;
    using System.Linq;
    using mshtml;class Program
    {
    static void Main()
    {
    var ie = new SHDocVw.InternetExplorer();
    ie.Visible = true;
    ie.Navigate("http://www.alibaba.com/trade/search?fsb=y&IndexArea=company_en&CatId=&SearchText=beijing");

    Console.WriteLine("按任意键打开所有聊天窗口");
    Console.ReadKey(); var links = ((IHTMLDocument3)ie.Document).getElementsByTagName("a").Cast<IHTMLElement>().Where(a => (a.title??"") == "Chat with me");
    foreach (IHTMLElement link in links)
    {
    link.click();
    }
    }
    }