Announcement

Collapse
No announcement yet.

Internet Explorer Automation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Internet Explorer Automation

    I've been looking around the forums but haven't come across a way of easily interfacing with internet explorer and accessing the DOM. Below is an example that works in Python.

    Code:
    from  win32com.client import Dispatch
    import time
    ie = Dispatch("InternetExplorer.Application")
    ie.Visible = 1
    
    # Navigate to google
    ie.Navigate("http://www.google.com/")
    
    while (ie.ReadyState != 4): time.sleep(3)
    
    ie.Document.getElementById("q").Value = "test"
    The basic Idea is to be able to control internet explorer through PowerBASIC as if a user was entering information into forms and pressing submit buttons. I know its possible through OLE/COM but I have no idea where to start with that. Any ideas of what samples I can look at that might help me get started with something like this. Thanks.

    #2
    Looking through sample files...

    I found the Web Browser sample file that comes with PB and have been studying it. I looked through the WebBrowser.inc file and I saw the methods like Navigate, etc. However I didn't see anything that would allow me to directly access the DOM.

    Does anyone know if there's a modified inc file with those extra methods built in to do something similar to the python code? Or any help on what I might be able to do to recreate that functionality.

    So far I was thinking I could try programming my own method that parses the document and retrieves or sets values but I'm assuming creating a parser that can handle all the nuances of imperfect html code would be kind of hard.

    Comment


      #3
      However I didn't see anything that would allow me to directly access the DOM.
      These methods and properties are in MSHTML.TLB. Use the COM browser to generate an include file for them.
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


        #4
        Thanks!

        Ok, cool, I'll go and try that out right now.

        Comment


          #5
          Hmmm...

          Included the MSHTML but now compiler is complaining about an undefined type Tag__userBITMAP do you know where that definition is located.

          Comment


            #6
            If you're willing to use my new include files

            instead of the ones provided with the compiler, this is what you will need:

            Code:
            #COMPILE EXE
            #DIM ALL
            #INCLUDE "exdisp.inc"
            %USEHTMLWRAPPERS = 1
            #INCLUDE "mshtml.inc"
            
            FUNCTION PBMAIN () AS LONG
            
               LOCAL ie AS IWebBrowser2
               LOCAL pDoc AS IHTMLDocument2
               
               ie = NEWCOM "InternetExplorer.Application"
               IF ISNOTHING(ie) THEN EXIT FUNCTION
               ie.Visible = 1
               ie.Navigate UCODE$("http://www.google.com/")
            
               WHILE (ie.ReadyState <> 4)
                  apiSleep 3
               WEND
            
               pDoc = ie.Document
               IF ISOBJECT(pDoc) THEN
                  IHTMLDocument_setElementValueById(pDoc, "q", "test")
               END IF
               
            END FUNCTION
            Forum: http://www.jose.it-berater.org/smfforum/index.php

            Comment


              #7
              I have posted an example in my forum that explains step by step how to do it, It also clicks the submit button to perform the search.

              Forum: http://www.jose.it-berater.org/smfforum/index.php

              Comment

              Working...
              X
              😀
              🥰
              🤢
              😎
              😡
              👍
              👎