executing JavaScript from Python

Hamish Lawson hamish_lawson at yahoo.co.uk
Thu Feb 8 18:06:28 CET 2001


Geoff Talvola <gtalvola at NameConnector.com> wrote:

> On Windows, you can use Internet Explorer via COM:
>
> >>> from win32com.client.gencache import EnsureDispatch
> >>> ie = EnsureDispatch('InternetExplorer.Application')
> >>> ie.Navigate('http://localhost/javascript.html')
> >>> print ie.Document.documentElement.innerHTML
> <HEAD></HEAD>
> <BODY>
> <SCRIPT>
> document.write('Hello, World!')
> </SCRIPT>
> Hello, World! </BODY>
> >>>

I tried that out myself and got the error below. I'm using Python 2.0
with win32all build 135.

Traceback (most recent call last):
  File "C:\temp\test2.py", line 11, in ?
    print ie.Document.documentElement.innerHTML
  File "C:\Python\win32com\client\__init__.py", line 340, in __getattr__
    return apply(self._ApplyTypes_, args)
  File "C:\Python\win32com\client\__init__.py", line 334, in
_ApplyTypes_
    return self._get_good_object_(apply(self._oleobj_.InvokeTypes,
(dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None,
None, None, 0, -2147467259), None)


Hamish Lawson


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list