On 2005-06-02, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2005-06-01, Elliot Temple <[EMAIL PROTECTED]> wrote: > >> How do I make Python press a button on a webpage? > > You just do whatever action is specified for the form > containing the button. > >> I looked at urllib, but I only see how to open a URL with >> that. > > Guess what happens when you push that button: the browser > opens a URL. > >> 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? > > Find the <form> containing the button, and look to see what the > URL is specified. For Google, it looks something like this: > ><form action="/search" naem="f"> > > So, /search is the URL you open. > >> 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.) > > Sure. Just send back the field value in the normal manner > using a GET. > >> If someone could point me in the right direction it'd be appreciated. > > You need an introductory book on HTTP and HTML. > > If all you care about is a google query here's a python program > that prints the URL you need to open for a google query: > > #!/usr/bin/python > import urllib,sys,os > queryString="whatever you're searching for" > print 'http://www.google.com/search?'+urllib.urlencode({'q':queryString}) > > I presume you can figure out how to open the URL instead of > printing it?
Ah, never mind. That doesn't work. Google somehow detects you're not sending the query from a browser and bonks you. -- Grant Edwards grante Yow! ... I'm IMAGINING a at sensuous GIRAFFE, CAVORTING visi.com in the BACK ROOMof a KOSHER DELI -- -- http://mail.python.org/mailman/listinfo/python-list