Home > Software engineering >  VB access web framework source code
VB access web framework source code

Time:10-02

Framework source code to obtain the prompt: real-time error, refused to visit
On the same page with multiple frames, some framework can get the source code, and some will prompt error
Finally found that seems to be qualified prompt error framework are source
I used to get framework source code is WebBrowser1 document. The frames (0). The document. The documentElement. OuterHTML
Want to ask how to settle this problem

CodePudding user response:

Before met... Did not delve into and was directly to use Edanmo 's OLE interface & amp; Functions provides... (that is, reference olelib. TLB) directly to the webbrowser all the document into a document in the array, and then simple...

CodePudding user response:

How upstairs into the array, this method seems to be good,

CodePudding user response:

refer to the second floor bcrun response:
how upstairs into the array, this method seems to be good,

Reference: http://blog.csdn.net/lbuskeep/article/details/6208676

CodePudding user response:

Look at my blog, there is the source code

CodePudding user response:


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
The Set of Doc2=Web2. Document
'MsgBox "the word is:" in the framework for web & amp; Doc2. Body. The innerText
End the If
End Sub
'the following three methods used for,82,28 130 microseconds (=1 million microseconds, a second=1000 milliseconds, 1 millisecond=1000 microseconds)


The 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
The Set FrameWeb=Vtag
If FrameWeb. LocationURL Like LikeUrl Then

The Set GetFrameIframeLikeUrl=FrameWeb
The Exit Function
End the If
End the If
Next
End the Function


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

Dim FrameWeb As WebBrowser_V1, MyFrames As Object, As Long I
The Set MyFrames=Vdoc. GetElementsByTagName (" FRAME ")
For I=0 To MyFrames. Length - 1
The Set FrameWeb=MyFrames (I)
If FrameWeb. LocationURL Like LikeUrl Then

The Set GetFrameLikeUrl=FrameWeb
The Exit Function
End the If
Next

End the Function
The Function FindFrameByUrl (Doc As HTMLDocument, LikeUrl As String) As WebBrowser_V1
Method 2: according to the site to get cross domain web
'DOC to handle webbrowser. DOCUMENT
'this method to reference OLELIB. TLB http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip


On the Error Resume Next
Dim pContainer As olelib. IOleContainer
Dim pEnumerator As olelib. IEnumUnknown
Dim pUnk As olelib. IUnknown
Dim pBrowser As WebBrowser_V1

The Set pContainer=Doc
If pContainer. EnumObjects (OLECONTF_EMBEDDINGS pEnumerator)=0 Then
The Do While pEnumerator. Next (1, pUnk)=0
The Set pBrowser=pUnk

If pBrowser. LocationURL Like LikeUrl Then
'can add condition judgment here to get the specified frame, basic can according to the url or innerHTML a key character in

The Set FindFrameByUrl=pBrowser

The Exit Do
End the If
Loop
The Set pEnumerator=Nothing
End the If
DoEnd:
The Set pContainer=Nothing

End the Function
'130,82,28
  • Related