javascript execution from Python script

Matt Gerrans matt_gerrans at hp.com
Tue Aug 27 13:37:57 EDT 2002


That works well -- you might also want to throw in an "ie.visible=1" so you
can see (and dismiss) it.

By the way (this should probably be a different thread), is this some
idiosycracy of my configuration:

>>> import win32com
>>> ie = win32com.client.DispatchEx('InternetExplorer.Application.1')
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
    ie = win32com.client.DispatchEx('InternetExplorer.Application.1')
AttributeError: 'module' object has no attribute 'client'
>>> import win32com.client
>>> ie = win32com.client.DispatchEx('InternetExplorer.Application.1')

Why is it necessary to import win32com.client explicitly in this case?


<brueckd at tbye.com> wrote in message
news:mailman.1030419340.11097.python-list at python.org...
> Here's a little code to help (untested but I've used similar stuff in the
> past):
>
> import win32com
> ie = win32com.client.DispatchEx('InternetExplorer.Application.1')
> ie.Navigate(someURL)
> while ie.Busy:
>   time.sleep(0.05)
> doc = ie.Document
> while not (hasattr(doc, 'readyState') and doc.readyState =='complete'):
>   time.sleep(0.05)
> pw = doc.parentWindow
> pw.execScript("window.alert('foo');") # Your javascript code
>
> Hope this helps,
> -Dave






More information about the Python-list mailing list