I'd suggest keeping it simple. Maybe something like this:
def search():
import urllib
q = request.args(0)
result1 = urllib.open('http://www.google.com/search?q=%s' % q)
result2 = urllib.open('http://www.bing.com/search?q=%s' % q)
result = result1 + result2
return dict(result=result)
You would of course need to parse out just the results. Or grab search
results through some sort of API.
Then something like this would trigger results:
<form method=get action=/search> or <form method=get
action={{=URL('search')}}>
<input name=q>
<input type=submit value=search>
</form>
On Wednesday, May 23, 2012 3:22:27 PM UTC-7, adohertyd wrote:
>
> I'm new to both python and web2py. I'm trying to build a meta-search
> engine and I need the search box to send the user input to a python script
> which will pre-process the query and obtain the results from 3 different
> search engines. I've created a very basic HTML form as in the example in
> the book, but I need it to be sent to the python script (controller?
> default.py ??) instead of redirecting to a new HTML page. Any help would be
> really appreciated