vb-the simplest way to access Web pages across domains, get a specific frame for processing

Source: Internet
Author: User

vb-the simplest way to access Web pages across domains, get a specific frame for processing

The following three methods take time of 130,82,28 microseconds (one second = 1 million microseconds, =1000 milliseconds, 1 milliseconds =1000 microseconds)

Private Sub Command1_Click () Dim Doc2 as Htmldocumentdim 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 are nothing and then Set Doc2 = Web2.document ' MsgBox ' The text in the frames page is: "& Doc2.body.innerTextEnd IfEnd Sub ' Three methods are used in 130,82,28 microseconds (one second = 1 million microseconds, =1000 milliseconds, 1 milliseconds =1000 microseconds) Function Getframeiframelikeurl (Vdoc as HTMLDocument, Likeurl as String) as Webbrowser_v1dim Vtag, tname As String, frameweb as WebB            Rowser_v1for 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 ifnextend functionfunction 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 as Likeurl Then Set Getframelikeurl = frameweb Exit Function End If Next End Functionfunction Find Framebyurl (Doc as HTMLDocument, Likeurl as String) as Webbrowser_v1 ' Method 2: Get cross-domain web ' Doc for the webbrowser.document ' to be processed by URL This method is to refer to 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, PEn Umerator) = 0 Then does while Penumerator.next (1, pUnk) = 0 Set pbrowser = pUnk If pBr Owser. Locationurl like Likeurl Then ' can be here to add conditions to determine the frame, the basic can be based on UOne of the key characters in RL or innerHTML Set findframebyurl = Pbrowser Exit do End If Loop Set penumerator = Nothing end ifdoend:set Pcontainer = Nothing End Function ' 130, 82, 28


vb-the simplest way to access Web pages across domains, get a specific frame for processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.