If you haven't read the initial About Visual Basic articles about the Google API, you might want to browse them first. But after trying out the "canned" program that is included in the Google API download, you should be ready to write one of your own. We see how to do that here.
Web Services One of the fastest growing sources of help, information, and business opportunites on the Internet. An introduction to one of the most popular and easy to use web services - the Google search service - is available in this article. And a review of a book devoted to explaining the Google service was reviewed in this article. But these only show you the "canned" application that Google provides. This time, we're going to write a complete and (Who knows?) maybe even a useful application for your desktop using the Google web service API. The goal is to provide a deeper understanding about how to program a client against a web service.
Have you ever been reading something online and discovered something that you wanted to know more about? I know I have. The way you might do it now is ...
- Copy a word or phrase from the page you're reading ... that is, if you're thinking really clearly and you remember that you'll need it.
- Open another browser window. Go to the Google homepage if you don't have the Google toolbar installed.
- Paste or type some search words in Google.
- Start scanning the results while you lose your train of thought on the original page.
Wouldn't it be nicer if you could just double click words in the article you're reading and have Google look for them automatically?
With the program we're going to write, you can do something very close to that. All you have to do is copy and paste the text of the article into a text window and read it there. Then, if you run across a word or phrase that you want to know more about, just double click it. The program will do the rest.
This program is written in VB .NET for the simple reason that it's a lot easier and faster to write a web service client in VB .NET. It's certainly possible (and ... it's really not THAT hard) to do it in VB 6, but we'll save that for another article.
The program is written as two VB .NET "forms". The first form has a simple text box to contain the article you want to read, and another text box to change the number of Google "hits" you want to retrieve. (The Google API currently limits you to ten, however.)
Click Here to see an example of the first form. Click the "Back" button in your browser to return.
The other form displays the title of one hit, the URL address of the hit, and the text snippet describing the hit returned by Google. A Next button allows you to traverse forward through the hits and an Exit button takes you back to the main form. An informational label tells you where you are in the sequence of hits.
Click Here to see an example of the second form. Click the "Back" button in your browser to return.