Description
In this homework, you will implement your own search engine interface,
using the Google API for
back-end searching.
At http://www.google.com/apis/ you can download the developer's toolkit and register with Google for API access.
There are a number of places to see some examples of usage of the Google API. One is from O'Reilly.
While Google provides example code for a few languages, others have created samples of many more. SoapWare for the Google API has links to example code in many languages as well as online applications.
If you do not already have a Web page on the CSE/ECE machines, you'll need to create a directory called WWW-data in your home directory. In that, create an index.html file. If all permissions are set correctly, that file will be shown when someone views
By permissions, I mean that the WWW-data will need to be set to world readable and executable, and your home directory must be world executable. A normal HTML file also needs to be world readable. The CGI files you create will additionally need to be executable.
For this assignment you'll also need to create a directory called cgi-bin within your WWW-data directory. In there you will place your CGI program. For security purposes, we do not generally allow users to have their own CGIs on the departmental webservers. Therefore, your CGI programs will run on a different machine, called wwwtest.eecs.lehigh.edu. Additionally, only clients from on-campus will be able to run your CGIs. This machine is currently not a Sun (it's a PC running Linux). This means that if you compile a program on the Suns, and try running it on wwwtest, it will not work. Scripted programs (sh, perl, etc.) will work if the script knows where to find the interpreter. If you need to compile, you will first need to log into wwwtest directly. But for scripts, you can edit your programs on any of the Suns.
If you have problems with that machine, first get a fellow student to replicate the problem, and then send mail to me and to help@cse.lehigh.edu.
If you've never written CGI scripts, or HTML forms, you might want to look at some tutorials on the net (note that all of these were listed in the first page of results from Google, using the search terms "cgi forms"):
Note that for many (all?) CGI interfaces, including the one on wwwtest, you have the option of generating HTTP header lines, as I do (to set the content type) in my examples below, and the requirement to put a blank line to signify the end of the HTTP headers. If you do not have that blank line, you'll get mysterious errors saying your script couldn't be run (in this case, because it did not generate valid HTTP).
The CGI you create will have to have .cgi as its extension in order for the Web server to try to execute it.
Some examples
If you are on campus, you can run a very simple CGI of mine as:
If you are off-campus, you can try using the Lehigh proxy server to make it look like you are on-campus. If you were to try accessing it through the usual machines (e.g., www.cse or www.ece or www.eecs), you'll instead be able to read the file (assuming permissions are set appropriately). You might want to read my simple Perl source code: http://www.cse.lehigh.edu/~brian/cgi-bin/test.cgi
I have a second simple CGI that is a shell script that you can run or view.
Your job is to write your own HTML form and CGI (in whatever language you wish) to send a user's query to Google via your key and display the results. The resulting interface can be simple, or complicated, but should be your own -- do not just copy Google's interface or anyone else's.
You need to send me the URL of the page where I can put in some search terms, hit a button, and see the results.