// 先添加引用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(); } } }
// 先添加引用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();
}
}
}