Another MSIE Python Question

Discussion in 'Python' started by Ralph A. Gable, Jun 19, 2004.

  1. I am opening MSIE6 with this code:

    ie=Dispatch('InternetExplorer.Application.1')
    ie.Navigate(url)
    while ie.Busy:
    time.sleep(0.1)
    ied=ie.Document
    while ied.ReadyState != 'complete':
    time.sleep(0.1)

    ieh=ied.documentElement.outerHTML


    When opening Word or Excel, and using Dispatch('Word.Application') or
    Dispatch('Excel.Application'), the app comes up and is available and can be
    brought up on the screen by setting .Visible = 1. When using the above code,
    IE will not come up. I have to open IE by clicking on its icon and then the
    above code will work. If I don't do that I get a stack dump and my python
    program crashes.

    Any help would be appreciated.
    Ralph A. Gable, Jun 19, 2004
    #1
    1. Advertising

  2. Ralph A. Gable

    Peter Hansen Guest

    Ralph A. Gable wrote:

    > I am opening MSIE6 with this code:
    >
    > ie=Dispatch('InternetExplorer.Application.1')
    > ie.Navigate(url)
    > while ie.Busy:
    > time.sleep(0.1)
    > ied=ie.Document
    > while ied.ReadyState != 'complete':
    > time.sleep(0.1)
    >
    > ieh=ied.documentElement.outerHTML
    >
    >
    > When opening Word or Excel, and using Dispatch('Word.Application') or
    > Dispatch('Excel.Application'), the app comes up and is available and can be
    > brought up on the screen by setting .Visible = 1. When using the above code,
    > IE will not come up. I have to open IE by clicking on its icon and then the
    > above code will work. If I don't do that I get a stack dump and my python
    > program crashes.
    >
    > Any help would be appreciated.


    Based on the above description, is it possible that the fact
    that you aren't doing "ie.Visible = 1" is responsible?

    Also, please include the traceback when saying that your Python program
    crashes... this usually eliminates whole classes of possible causes,
    and often points directly to the trouble for someone who's been there
    before.

    -Peter
    Peter Hansen, Jun 19, 2004
    #2
    1. Advertising

  3. Ralph A. Gable wrote:
    > I am opening MSIE6 with this code:
    >
    > ie=Dispatch('InternetExplorer.Application.1')
    > ie.Navigate(url)
    > while ie.Busy:
    > time.sleep(0.1)
    > ied=ie.Document
    > while ied.ReadyState != 'complete':
    > time.sleep(0.1)
    >
    > ieh=ied.documentElement.outerHTML
    >
    >
    > When opening Word or Excel, and using Dispatch('Word.Application') or
    > Dispatch('Excel.Application'), the app comes up and is available and can

    be
    > brought up on the screen by setting .Visible = 1. When using the above

    code,
    > IE will not come up. I have to open IE by clicking on its icon and then

    the
    > above code will work. If I don't do that I get a stack dump and my python
    > program crashes.


    My working code is similar to yours, but I use
    'InternetExplorer.Application' instead of 'InternetExplorer.Application.1'
    in the Dispatch call. I wonder if that could make the difference.

    -Mike
    Michael Geary, Jun 19, 2004
    #3
  4. Here's the stack dump:
    Traceback (most recent call last):
    File "<interactive input>", line 1, in ?
    File "C:\Python22\lib\ufutil.py", line 661, in updatetocurrent
    getplayerdata(l,i)
    File "C:\Python22\lib\ufutil.py", line 478, in getplayerdata
    ie=Dispatch('InternetExplorer.Application.1')
    File "C:\Python22\lib\site-packages\win32com\client\__init__.py",
    line 95, in Dispatch
    dispatch, userName =
    dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
    File "C:\Python22\lib\site-packages\win32com\client\dynamic.py",
    line 84, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
    File "C:\Python22\lib\site-packages\win32com\client\dynamic.py",
    line 72, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
    pythoncom.IID_IDispatch)
    com_error: (-2147221231, 'ClassFactory cannot supply requested class',
    None, None)


    Peter Hansen <> wrote in message news:<>...
    > Ralph A. Gable wrote:
    >
    > > I am opening MSIE6 with this code:
    > >
    > > ie=Dispatch('InternetExplorer.Application.1')
    > > ie.Navigate(url)
    > > while ie.Busy:
    > > time.sleep(0.1)
    > > ied=ie.Document
    > > while ied.ReadyState != 'complete':
    > > time.sleep(0.1)
    > >
    > > ieh=ied.documentElement.outerHTML
    > >
    > >
    > > When opening Word or Excel, and using Dispatch('Word.Application') or
    > > Dispatch('Excel.Application'), the app comes up and is available and can be
    > > brought up on the screen by setting .Visible = 1. When using the above code,
    > > IE will not come up. I have to open IE by clicking on its icon and then the
    > > above code will work. If I don't do that I get a stack dump and my python
    > > program crashes.
    > >
    > > Any help would be appreciated.

    >
    > Based on the above description, is it possible that the fact
    > that you aren't doing "ie.Visible = 1" is responsible?
    >
    > Also, please include the traceback when saying that your Python program
    > crashes... this usually eliminates whole classes of possible causes,
    > and often points directly to the trouble for someone who's been there
    > before.
    >
    > -Peter
    Ralph A. Gable, Jun 20, 2004
    #4
  5. Ralph A. Gable

    Peter Hansen Guest

    Ralph A. Gable wrote:

    [traceback snipped]

    So what if you drop the '.1' from the end of the AppId, and
    also make sure you have the "ie.Visible = 1" in there?

    Can you upgrade to the latest versions of Python and pywin32
    as well? I notice you are using 2.2 still...

    (No idea if any of these things will help... I'm spending a
    lot of time struggling with COM right now as well, though
    with troubles in entirely different areas.)

    -Peter
    Peter Hansen, Jun 20, 2004
    #5
  6. I have dropped the .1. I don't even get to the point where I CAN set
    ..Visible=1 since it crashes before it brings up msie.

    I guess I wasn't clear enough in the original message. What I want to
    do is be able to bring up an instance of msie (and NOT make if
    visible) that python can use and that will not be seen by the user,
    i.e. I want all the operations I am performing with msie to be hidden
    from the user so said user can go about his/her business and never
    know anything is going on. In the case of Word/Excel I can do that
    with no problem. I just don't set .Visible to 1 but when trying to use
    msie (with python) I can't do it unless I already have an instance of
    msie running BEFORE I run the code cited below.


    Peter Hansen <> wrote in message news:<>...
    > Ralph A. Gable wrote:
    >
    > [traceback snipped]
    >
    > So what if you drop the '.1' from the end of the AppId, and
    > also make sure you have the "ie.Visible = 1" in there?
    >
    > Can you upgrade to the latest versions of Python and pywin32
    > as well? I notice you are using 2.2 still...
    >
    > (No idea if any of these things will help... I'm spending a
    > lot of time struggling with COM right now as well, though
    > with troubles in entirely different areas.)
    >
    > -Peter
    Ralph A. Gable, Jun 20, 2004
    #6
  7. (Ralph A. Gable) wrote in message news:<>...
    > I am opening MSIE6 with this code:
    >
    > ie=Dispatch('InternetExplorer.Application.1')
    > ie.Navigate(url)
    > while ie.Busy:
    > time.sleep(0.1)
    > ied=ie.Document
    > while ied.ReadyState != 'complete':
    > time.sleep(0.1)
    >
    > ieh=ied.documentElement.outerHTML
    >



    I have tried your code as is (added imports, of course) and it worked.
    IE didn't show up in taskbar, url was loaded and outerHTML contained,
    well, HTML :)

    Test environment: Win2k, MSIE 6 and ActivePython 2.3.

    - kv
    Konstantin Veretennicov, Jun 21, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Koen
    Replies:
    2
    Views:
    1,333
    Scott G.
    Jun 28, 2004
  2. Mike Novak

    MSIE and scrollbar question

    Mike Novak, Jul 3, 2003, in forum: HTML
    Replies:
    1
    Views:
    415
  3. Claudio Grondi

    Python Scripting in Windows MSIE 6.0

    Claudio Grondi, Jun 10, 2004, in forum: Python
    Replies:
    2
    Views:
    284
    Claudio Grondi
    Jun 11, 2004
  4. Claudio Grondi

    Python Scripting in Windows MSIE 6.0

    Claudio Grondi, Jun 10, 2004, in forum: Python
    Replies:
    0
    Views:
    290
    Claudio Grondi
    Jun 10, 2004
  5. John J. Lee

    Python Scripting in Windows MSIE 6.0

    John J. Lee, Jun 10, 2004, in forum: Python
    Replies:
    6
    Views:
    349
    Neil Hodgson
    Jun 12, 2004
Loading...

Share This Page