Hack 98 Search or Browse Amazon with Watson


You can use Watson's interface to find items at Amazon or integrate Amazon's data into other Mac applications.

An alternative way to access Amazon.com if you're a Mac user is to use Watson, from Karelia Software. Watson is a "Swiss army knife" of over 20 tools that access the most useful web services. Along with movie and TV listings, package tracking, telephone lookup, weather forecasts, online recipes, searching, translation, and more, Watson also features a tool for browsing and searching Amazon.com through their API.

Watson's Amazon.com tool is divided into four sections, organized vertically (see Figure 6-12). At the top of the window (below the optional toolbar for easy access to other tools) is the search field. The user selects which "store" to search within, or a particular aspect of the selected store (such as searching by ASIN or UPC number, actor or director, etc.), enters a search term, and clicks the Find button.

Figure 6-12. Amazon and Watson integration

The second section is the browser, which allows the user to browse the store hierarchically. The main stores appear in the leftmost column, and as the user selects an item, the columns to the right populate with lists of subcategories.

The third section is the result list, displaying either the search results or the featured items for a selected category. Only 10 items are loaded at a time; pressing the down arrow below the list will append another "page" to the list. Select an item in the list and press the "Buy selected items from Amazon.com" button to add it to your shopping cart.

Finally, the "drawer" below displays details about the item currently selected in the results list. On the left, a thumbnail of the item is displayed; click the little magnifying glass icon to pop up a larger version of the image. A list of details about the selected item alternates with a list of reviews for the product.

98.1 Integrate with Other Tools

Watson's Amazon.com tool provides a number of ways to export data. Details about the selected item can be copied to the clipboard and pasted as text. The user can also drag out from the thumbnail image to export additional textual details (if dragged onto a text editor) or the large version of the image (if dragged onto the Mac's desktop or a graphics program, or even onto iTunes 4 to fill in the album cover art as you see in Figure 6-13).

Figure 6-13. Amazon data from Watson integrating with iTunes

Similarly, Figure 6-14 shows dragging the image into Spring from UserCreations to instantiate a "Spring Object" of that project.

Figure 6-14. Amazon data from Watson integrating with Spring

98.2 How It Works

The Amazon.com tool on Watson depends mostly on Amazon Web Services. Mac OS X Version 10.2 and up contains built-in support for Web Services through SOAP, since it was built under (and is still compatible with) earlier versions of Mac OS X. However, Watson instead uses the simple XML/HTTP interface to get the XML data, and then parses the XML to populate the user interface.

One major aspect of the tool that doesn't use Web Services is the category-browsing capability. The Browse IDs [Hack #8] for the subcategories of a given category are obtained by scraping Amazon's site. When the user clicks on a category in the browser to load up the subcategories, an HTML page that contains the list of subcategories is loaded. The list of subcategories is parsed, and the list of Browse IDs is cached for two weeks.

?Dan Wood