J Correia wrote: > "Elliot Temple" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>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 > ie.Navigate("http://www.google.com") > while ie.ReadyState != 4: # Wait for browser to finish loading. > sleep(1) > 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 Navigate. /Esben -- http://mail.python.org/mailman/listinfo/python-list