2013年9月12日星期四

c # How to automatically Ali are opening the

For example, enter : http://www.alibaba.com/trade/search?fsb=y&IndexArea=company_en&CatId=&SearchText=beijing this page , this page has a lot of Want , how to achieve on this page automatically Want all point to open .
------ Solution ---------------------------------------- ----

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

没有评论:

发表评论