html + javascript automations = [mechanize + ?? ] or something else?

Duncan Booth duncan.booth at invalid.invalid
Tue Jan 16 12:51:06 CET 2007

"John" <weekender_ny at> wrote:

> Is there a way
> to control a browser like firefox from python itself? How about IE?

IE is easy enough to control and you have full access to the DOM:

>>> import win32com
>>> win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-
0000C05BAE0B}', 0, 1, 1)
<module 'win32com.gen_py.EAB22AC0-30C1-11CF-A7EB-0000C05BAE0Bx0x1x1' from 
>>> IE = win32com.client.DispatchEx('InternetExplorer.Application.1')
>>> dir(IE)
['CLSID', 'ClientToWindow', 'ExecWB', 'GetProperty', 'GoBack', 'GoForward', 
'GoHome', 'GoSearch', 'Navigate', 'Navigate2', 'PutProperty', 
'QueryStatusWB', 'Quit', 'Refresh', 'Refresh2', 'ShowBrowserBar', 'Stop', 
'_ApplyTypes_', '__call__', '__cmp__', '__doc__', '__getattr__', 
'__init__', '__int__', '__module__', '__repr__', '__setattr__', '__str__', 
'__unicode__', '_get_good_object_', '_get_good_single_object_', '_oleobj_', 
'_prop_map_get_', '_prop_map_put_', 'coclass_clsid']
>>> IE.Visible=True
>>> IE.Navigate("")
>>> while IE.Busy: pass

>>> print IE.Document.getElementById("portlet-news").innerHTML
<DT class=portletHeader><A class="feedButton link-plain" 
href="feed://"><IMG title="RSS subscription 
feed for news items" alt=RSS src=""> </A><A 
href="">News</A> </DT>

... and so on ...

for the documentation.

More information about the Python-list mailing list