vb6的frame在html中如何提现,vb-跨域访问网页最简单方法,获得特定的frame进行处理...

vb-跨域访问网页最简单方法,获得特定的frame进行处理

以下三种方法所用时间为130,82,28 微秒(一秒=100万微秒,=1000毫秒,1毫秒=1000微秒)

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中的某个关键字符

Set FindFrameByUrl = pBrowser

Exit Do

End If

Loop

Set pEnumerator = Nothing

End If

DoEnd:

Set pContainer = Nothing

End Function

'130,82,28

原文:http://blog.csdn.net/xiaoyao961/article/details/41449395

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值