µ±Ç°Î»ÖãºÊ×Ò³ -> ×ÛºÏƵµÀ -> Õ¾³¤Ö®¼Ò

vb-¿çÓò·ÃÎÊÍøÒ³×î¼òµ¥·½·¨£¬»ñµÃÌض¨µÄ..

Private Sub Command1_Click()

Dim Doc2 As HTMLDocument

Dim Web2 As WebBrowser_V1

Set Web2 = GetFrameIframeLikeUrl(WebBrowser1.Document, "*baidu.com*")

Set Web2 = GetFrameLikeUrl(WebBrowser1.Document, "*baidu.com*")

Set Web2 = FindFrameByUrl(WebBrowser1.Document, "*baidu.com*")


If Not Web2 Is Nothing Then

   Set Doc2 = Web2.Document

   'MsgBox "¿ò¼ÜÍøÒ³ÖеÄÎÄ×ÖÊÇ£º" & Doc2.body.innerText

End If

End Sub

'ÒÔÏÂÈýÖÖ·½·¨ËùÓÃʱ¼äΪ130,82,28 ΢Ã루һÃë=100Íò΢Ãë,=1000ºÁÃ룬1ºÁÃë=1000΢Ãë)



Function GetFrameIframeLikeUrl(Vdoc As HTMLDocument, LikeUrl As String) As WebBrowser_V1


Dim Vtag, Tname As String, FrameWeb As WebBrowser_V1

For Each Vtag In Vdoc.All

       Tname = Vtag.tagName

       If Tname = "IFRAME" Or Tname = "FRAME" Then

           Set FrameWeb = Vtag

             If FrameWeb.LocationURL Like LikeUrl Then

                 Set GetFrameIframeLikeUrl = FrameWeb

                 Exit Function

            End If

       End If

Next

End Function



Function GetFrameLikeUrl(Vdoc As HTMLDocument, LikeUrl As String) As WebBrowser_V1

     Dim FrameWeb As WebBrowser_V1, MyFrames As Object, I As Long

     Set MyFrames = Vdoc.getElementsByTagName("FRAME")

     For I = 0 To MyFrames.length - 1

       Set FrameWeb = MyFrames(I)

       If FrameWeb.LocationURL Like LikeUrl Then

       

            Set GetFrameLikeUrl = FrameWeb

            Exit Function

       End If

     Next

     

End Function

Function FindFrameByUrl(Doc As HTMLDocument, LikeUrl As String) As WebBrowser_V1

'·½·¨2£º°´ÍøÖ·µÃµ½¿çÓòµÄweb

''DOCΪҪ´¦ÀíµÄwebbrowser.DOCUMENT

'Õâ¸ö·½·¨ÒªÒýÓÃOLELIB.TLB  http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip


On Error Resume Next

   Dim pContainer As olelib.IOleContainer

   Dim pEnumerator As olelib.IEnumUnknown

   Dim pUnk As olelib.IUnknown

   Dim pBrowser As WebBrowser_V1

 

   Set pContainer = Doc

   If pContainer.EnumObjects(OLECONTF_EMBEDDINGS, pEnumerator) = 0 Then

      Do While pEnumerator.Next(1, pUnk) = 0

         Set pBrowser = pUnk

         

            If pBrowser.LocationURL Like LikeUrl Then

            '¿ÉÒÔÔÚÕâÀï¼ÓÌõ¼þÅжϵõ½Ö¸¶¨µÄframe£¬»ù±¾¿ÉÒÔ¸ù¾Ýurl»òÕßinnerHTMLÖеÄij¸ö¹Ø¼ü×Ö·û

     

               Set FindFrameByUrl = pBrowser

               

               Exit Do

           End If

      Loop

      Set pEnumerator = Nothing

   End If

DoEnd:

      Set pContainer = Nothing

   

End Function

'130,82,28


²ÂÄãϲ»¶