home > anthracite > docs > examples > AppleScript the Google API
AppleScripting the Google API Using Anthracite
Beginning with Anthracite version 1.1, the Google API Source Object is AppleScriptable.
This enables you to automate your processes that make use of the Google API with multiple query terms and index parameters. For example, if you use Anthracite and the Google API to produce a daily report on top keywords for your search term, you can now automate it to produce multiple reports for multiple different search terms and resulting keywords. Examples of these types of processes and sample scripts are included on the current Anthracite distribution disk.
To make use of the Google API Source Object in Anthracite using AppleScript, first create an Anthracite document and construct your process for a single Google search term as you would normally. Since this could be any imaginable process of your design, we're just going to focus on the Source Object here.

In our example, we're going to configure our search to query the term "Sushi" and return the first 100 websites that match.

As you can imagine, running this script will return a list of 100 matching sites, we can then process this list in a variety of ways. (See "GoogleReport-Coffee" in the example documents.)
Now, presuming we like the way our process is set up, we're ready to create the AppleScript.
First, let's take a look at the simple AppleScript Dictionary for the Google API, look in "Anthracite Suite" once you've opened Anthracite's dictionary in Script Editor.
With this information, we can write a sample Google API AppleScript that sets the keyword to "Sushi" and requests 100 results starting with result number one, that is, exactly what we configured manually above.
Now, we're ready to write an AppleScript that changes this information, a simple example would be another script that just has different details filled in, like so:

Note that we also added a "run document" command that will actually cause the Anthracite process to be run for us, too.
If we run this script and then return to Anthracite and double-click the Google Source Object to review its settings, we'll now find this:
Onto a more advanced example now, in this next script, we'll actuall use a list of query terms to to drive our Anthracite Google API searches.
Once you've constructed your Anthracite process and associated AppleScripts, you can set them up to be run on a regular periodic basis using iCal, as explained in this sample document:
How To Schedule Web Mining with Anthracite and iCal
[ Anthracite Examples ] [ Metafy Home ]
Last Updated: 5/9/2005
Copyright © 2005, All Rights Reserved, Metafy LLC.