<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="600" height="410">
      <param name="movie" value="tlsh.swf" />
      <param name="quality" value="high" />
      <embed src="tlsh.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="600" height="410"></embed>
    </object>请问如何才能提取到<embed>中的src="t1sh.swf"??
急啊,请大侠们帮帮忙了……

解决方案 »

  1.   

    http://mgd0629.blog.163.com/blog/static/64948503200782433531902/参考
      

  2.   

    你的是IHTMLDocument 的接口,不过你可以通过IHTMLDocument 去QueryInterface IHTMLDocument3
    IHTMLDocument3中有个函数getElementsByTagName,然后过滤出你想要的那个HTMLELEMENT,得到HTMLELEMENT了之后getAttribute()函数可能会得到你想要的,不妨试试。 
      

  3.   

    “a.htm”的部分源码如下:
    <table width="640px" height="440" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tdheight">
      <tr>
        <td valign="top"><iframe frameborder="0" height="440px" width="100%" src="a1.htm" id="winall" name="winall" title="winall"></iframe></td>
      </tr>
    </table>
    其中嵌入了"a1.htm"
    "a1.htm"中的源码如下:
    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="300">
          <param name="movie" value="an.swf" />
          <param name="quality" value="high" />
          <embed src="an.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="300"></embed>
        </object></td>
      </tr>
    </table>
    </body>
    现在的具体情况是这样的:
    当我把鼠标放在"a.htm"中的<iframe>上时,我能提取它的src="a1.htm" ,然后我又用一个CWebBrowser2对象打开"a1.htm"。用IHTMLDocument2::get_embeds()和IHTMLDocument2::get_all()都能得到一个有效的IHTMLElementCollection的指针,但是然后使用IHTMLElementCollection::get_length()得到的值始终为0,
    问题就出在这个里,请问怎样解决?
      

  4.   

    用IHTMLDocument2::get_embeds()和IHTMLDocument2::get_all()都能得到一个有效的IHTMLElementCollection的指针,但是然后使用IHTMLElementCollection::get_length()
    ------------------------------
    这些代码贴出来
      

  5.   

    //1.用IHTMLDocument2::get_embeds()
    CWebBrowser2 *ptempWeb = (CWebBrowser2 *)GetDlgItem(IDC_EXPLORER2);
    ptempWeb->Navigate(tempPath, 0, 0, 0, 0);
    long len=0;
    HRESULT temphr = S_OK;
    IHTMLElement *templink = NULL;
    IHTMLDocument2* ptempHTMLDoc = NULL;
    IDispatch* ptempDoc=ptempWeb->GetDocument();
    ptempDoc->QueryInterface(IID_IHTMLDocument2, (void**)&ptempHTMLDoc);
    CComQIPtr< IHTMLElementCollection > pElementCollectionEmbeds;
    ptempHTMLDoc->get_embeds(&pElementCollectionEmbeds);
    pElementCollectionEmbeds->get_length(&len); CWebBrowser2 *ptempWeb = (CWebBrowser2 *)GetDlgItem(IDC_EXPLORER2);
    //2.用IHTMLDocument2::get_all() ptempWeb->Navigate(tempPath, 0, 0, 0, 0);
    long len=0;
    HRESULT temphr = S_OK;
    IHTMLElement *templink = NULL;
    IHTMLDocument2* ptempHTMLDoc = NULL;
    IDispatch* ptempDoc=ptempWeb->GetDocument();
    ptempDoc->QueryInterface(IID_IHTMLDocument2, (void**)&ptempHTMLDoc);
    CComQIPtr< IHTMLElementCollection > pElementCollectionAll;
    ptempHTMLDoc->get_all(&pElementCollectionAll);
    BSTR bstrObject;
    CString strObject;
    pElementCollectionAll->toString(&bstrObject);
    strObject = SysAllocString(bstrObject);//此处得到的是[object]
    pElementCollectionAll->get_length(&len);
    //两种方法得到解决的len全部是0
      

  6.   

    试试这样,枚举IHTMLElementCollection里面的IHTMLElement,然后IHTMLEmbedElement* pEmbed;
    pItem->QueryInterface(IID_IHTMLEmbedElement, (void**)&pEmbed);看能不能得到有效的IHTMLEmbedElement
      

  7.   


    bool CMyInternetExplorer::FindAnchor (bool bClick, bool bFocus,
          bool bName, bool bOuterText, bool bTooltip, bool bURL,
          LPCTSTR sName, LPCTSTR sOuterText, LPCTSTR sTooltip, LPCTSTR sURL)
    {
        ASSERT (m_pWebBrowser != NULL);
        if (m_pWebBrowser == NULL)
            return false;
        
        HRESULT hr;
        IDispatch* pHtmlDocDispatch = NULL;
        IHTMLDocument2 * pHtmlDoc = NULL;
        bool bSearch = true;    // Retrieve the document object.    hr = m_pWebBrowser->get_Document (&pHtmlDocDispatch);
        if (SUCCEEDED (hr) && (pHtmlDocDispatch != NULL))
        {
            hr = pHtmlDocDispatch->QueryInterface 
                (IID_IHTMLDocument2,  (void**)&pHtmlDoc);
            if (SUCCEEDED (hr) && (pHtmlDoc != NULL))
            {
                IHTMLElementCollection* pColl = NULL;
                hr = pHtmlDoc->get_all (&pColl);            if (SUCCEEDED (hr) && (pColl != NULL))
                {
                    // Obtained the Anchor Collection...                long nLength = 0;
                    pColl->get_length (&nLength);
                    
                    for (int i = 0; i < nLength && bSearch; i++)
                    {
                        COleVariant vIdx ((long)i, VT_I4);
                        
                        IDispatch* pElemDispatch = NULL;
                        IHTMLElement * pElem = NULL;
                        
                        hr = pColl->item (vIdx, vIdx, &pElemDispatch);
                        
                        if (SUCCEEDED (hr) && 
                                     (pElemDispatch != NULL))
                        {
                            hr = pElemDispatch->QueryInterface 
                               (IID_IHTMLElement, (void**)&pElem);
                            
                            if (SUCCEEDED (hr) && (pElem != NULL))
                            {
                                BSTR bstrTagName;
                                CString sTempTagName;
                                if (!FAILED (pElem->get_tagName 
                                                     (&bstrTagName)))
                                {
                                    sTempTagName = bstrTagName;
                                    SysFreeString (bstrTagName);
                                }
                                
                                if (sTempTagName == _T ("a") || 
                                            sTempTagName == _T ("A"))
                                {
                                    IHTMLAnchorElement * pAnchor = NULL;
                                    hr = pElemDispatch->QueryInterface
                                       (IID_IHTMLAnchorElement, 
                                       (void**)&pAnchor);
                                    
                                    if (SUCCEEDED (hr) && 
                                                   (pAnchor != NULL))
                                    {
                                        BSTR bstrName, bstrOuterText, 
                                                     bstrURL, bstrTooltip;
                                        CString sTempName, sTempOuter, 
                                                    sTempURL, sTempTooltip;
                                        
                                        if (!FAILED (pElem->get_outerText 
                                                          (&bstrOuterText)))
                                        {
                                            sTempOuter = bstrOuterText;
                                            SysFreeString (bstrOuterText);
                                        }
                                        if (!FAILED 
                                          (pElem->get_title 
                                          (&bstrTooltip)))
                                        {
                                            sTempTooltip = bstrTooltip;
                                            SysFreeString (bstrTooltip);
                                        }
                                        if 
                                          (!FAILED (pAnchor->get_name 
                                          (&bstrName)))
                                        {
                                            sTempName = bstrName;
                                            SysFreeString (bstrName);
                                        }
                                        if (!FAILED (pAnchor->get_href 
                                           (&bstrURL)))
                                        {
                                            sTempURL = bstrURL;
                                            SysFreeString (bstrURL);
                                        }                                    // Do the comparison here!                                    bool bMatches = true;
                                        if (bMatches && bName)
                                        {
                                          if 
                                          (!StringHelper::WildcardCompareNoCase 
                                          (sName, sTempName))
                                                bMatches = false;
                                        }
                                        if (bMatches && bOuterText)
                                        {
                                          if 
                                           (!StringHelper::WildcardCompareNoCase
                                           (sOuterText, sTempOuter))
                                                bMatches = false;
                                        }
                                        if (bMatches && bURL)
                                        {
                                          if
                                           (!StringHelper::WildcardCompareNoCase
                                           (sURL, sTempURL))
                                                bMatches = false;
                                        }
                                        if (bMatches && bTooltip)
                                        {
                                          if 
                                          (!StringHelper::WildcardCompareNoCase 
                                            (sTooltip, sTempTooltip))
                                                bMatches = false;
                                        }
                                        
                                        if (bMatches)
                                        {
                                            // No need to search more!                                        bSearch = false;
                                            
                                            if (bFocus)
                                                pAnchor->focus ();
                                            if (bClick)
                                                pElem->click ();
                                        }
                                        pAnchor->Release ();
                                    }
                                }
                                pElem->Release ();
                            }
                            pElemDispatch->Release ();
                        }        
                    }
                    pColl->Release ();
                }
                pHtmlDoc->Release();
            }
            pHtmlDocDispatch->Release ();
        }
        
        if (bSearch == false)
            return true;    return false;
    }
    搜索元素可尝试如上代码
      

  8.   

    http://vckbase.com/document/viewdoc/?id=288