By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

Another MSIE Python Question

P: n/a
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.
Jul 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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
Jul 18 '05 #2

P: n/a
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
Jul 18 '05 #3

P: n/a
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,userN ame,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 <pe***@engcorp.com> wrote in message news:<P8********************@powergate.ca>...
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

Jul 18 '05 #4

P: n/a
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
Jul 18 '05 #5

P: n/a
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 <pe***@engcorp.com> wrote in message news:<PM********************@powergate.ca>...
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

Jul 18 '05 #6

P: n/a
r.*****@mchsi.com (Ralph A. Gable) wrote in message news:<22************************@posting.google.co m>...
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
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.