Pressing A Webpage Button
n.20.e5ke at spamgourmet.com
Fri Jun 3 20:30:57 CEST 2005
J Correia wrote:
> "Elliot Temple" <curi at curi.us> wrote in message
> news:mailman.335.1117645705.18027.python-list at python.org...
>>How do I make Python press a button on a webpage? I looked at
>>urllib, but I only see how to open a URL with that. I searched
>>google but no luck.
>>For example, google has a button <input type=submit value="Google
>>Search" name=btnG> how would i make a script to press that button?
>>Just for fun, is there any way to do the equivalent of typing into a
>>text field like the google search field before hitting the button?
>>(I don't actually need to do this.)
> You don't say which OS... if you're running IE on Windows you
> can use COM as follows...
> from win32com.client import Dispatch
> from time import sleep
> ie = Dispatch("InternetExplorer.Application")
> ie.Visible = 1
> while ie.ReadyState != 4: # Wait for browser to finish loading.
> doc = ie.Document
> doc.f.q.value = "qwerty" # form name is 'f'; search field name is 'q'
> doc.f.btnG.click() # click on button 'btnG'
How do i know which methods the ie object has? dir(ie) doesn't show
More information about the Python-list