您将需要查询的HTML文档,检索采集。一旦你检索到集合,你需要遍历元素并点击它。
我正在粘贴代码片段(click here for the entire code)。这是在c + +中,但我认为它也必须是相同的VB。
IHTMLElementCollection *spCollectEmbed;
spDocument->get_links(&spCollectEmbed);
if(spCollectEmbed)
{
// get all the links
long lLen;
spCollectEmbed->get_length(&lLen);
for (long i = 0; i < lLen; i++)
{
IDispatch *ppvdispOption;
IHTMLElement *interfaceHTMLElement;
VARIANT index;
index.vt = VT_I4;
index.lVal = i;
// get the item from the document
HRESULT hResult = spCollectEmbed->item(index, index, &ppvdispOption);
if(SUCCEEDED(hResult))
{
// query for the element
hResult = ppvdispOption->QueryInterface(IID_IHTMLElement,
(void **) &interfaceHTMLElement);
if(SUCCEEDED(hResult))
{
BSTR innerhtml;
interfaceHTMLElement->get_innerHTML(&innerhtml);
// click the links
interfaceHTMLElement->click();
Sleep(2000);
}