if(linkDisp!=NULL)
{
linkDisp->QueryInterface(__uuidof(IHTMLElement), (void**)&link);//得到这个链接元素
link->get_innerHTML(&tagadd);
link->get_innerText(&tagname);
tagtext=tagname;
url=tagadd;
int nItem=m_urllist.InsertItem(i,url,0);
m_urllist.SetItemText(nItem,1,tagtext);
}

解决方案 »

  1.   

    比如得到
    tagname--->返回主页
    tagadd--->http://www.263.net
      

  2.   

    if(pHTMLDocument)
      {
       IHTMLElementCollection *pAnchors = NULL;
      if(SUCCEEDED(pHTMLDocument->get_all(&pAnchors)))
      {
      long ilHrefCount = 0;
      if(SUCCEEDED(pAnchors->get_length(&ilHrefCount)))
      {
                                 long ilHrefIndex = 0;
      for(; ilHrefIndex < ilHrefCount; ilHrefIndex++)
      {
      _variant_t vIndex;
      vIndex.vt = VT_I4;
      vIndex.lVal = ilHrefIndex;   IDispatch *pItem = NULL;
      pAnchors->item(vIndex, vIndex, &pItem);
      if(pItem != NULL)
      {
      IHTMLAnchorElement *pAnchor = NULL;
      if(SUCCEEDED(pItem->QueryInterface(IID_IHTMLAnchorElement,
      (LPVOID*)&pAnchor)))
      {   _bstr_t bURL;
      if(SUCCEEDED(pAnchor->get_href(&bURL)))
                              {
                                string s =  W2A(bURL);
                                vector<string>::iterator it = find(vstrings.begin(),vstrings.end(),s);                            if (it == vstrings.end() && s.length()>0)
                                    vstrings.push_back(s);                          }
      pAnchor->Release();
      }
      pItem->Release();
      }
      }
      }
      pAnchors->Release();
      }