Finding Recipes

advanced tipscreenshot tip92.gif

Let the Google API transform those random ingredients in your fridge into a wonderful dinner.

link

Google can help you find news, catalogs, discussions, web pages, and so much more - and it can also help you figure out what to have for dinner tonight!

This tip uses the Google API to help you transform those random ingredients in your fridge into a wonderful dinner. Well, you do have to do some of the work. But it all starts with this tip.

Using the Tip

This tip comes with a built-in form that calls the query and the recipe type, so there's no need to set up a separate form.

#!/usr/local/bin/perl
# goocook.cgi
# Finding recipes with google
# goocook.cgi is called as a CGI with form input
# Your Google API developer's key my $google_key='insert key here';
# Location of the GoogleSearch WSDL file my $google_wdsl = "./GoogleSearch.wsdl";
use SOAP::Lite;
use CGI qw/:standard/;
my %recipe_types = (
 "General" =» "site:allrecipes.com | site:cooking.com | site:
epicurious.com | site:recipesource.com",
 "Vegetarian/Vegan" =» "site:fatfree.com | inurl:veganmania | inurl:
vegetarianrecipe | inurl:veggiefiles",
 "Wordwide Cuisine" =» "site:Britannia.org | inurl:thegutsygourmet | 
inurl:simpleinternet | inurl:soupsong"
);
print
 header( ),
 start_html("GooCook"),
 h1("GooCook"),
 start_form(-method=»'GET'),
 'Ingredients: ', textfield(-name=»'ingredients'),
 br( ),
 'Recipe Type: ', popup_menu(-name=»'recipe_type', 
 -values=»[keys %recipe_types], -default=»'General'),
 br( ),
 submit(-name=»'submit', -value=»"Get Cookin'!"),
 submit(-name=»'reset', -value=»"Start Over"),
 end_form( ), p( );
if (param('ingredients')) {
 my $google_search = SOAP::Lite-»service("file:$google_wdsl");
 my $results = $google_search -» 
 doGoogleSearch(
 $google_key, 
 param('ingredients') . " " . $recipe_types{param('recipe_type')}, 
 0, 10, "false", "", "false", "", "latin1", "latin1"
 );
 @{$results-»{'resultElements'}} or print "None";
 foreach (@{$results-»{'resultElements'}}) {
 print p(
 b($_-»{title}||'no title'), br( ),
 a({href=»$_-»{URL}}, $_-»{URL}), br( ),
 i($_-»{snippet}||'no snippet')
 );
 }
}
print end_html( );

Tiping the Tip

Of course the most obvious way to tip this tip is to add new recipe options to it. That involves first finding new recipe sites, and then adding them to the tip.

Finding New Recipe Domains

Adding new recipe sites entails finding the domains you want to search. Use the cooking section of Google's Directory to find recipes; start with recipe collections
at http://directory.google.com/Top/Home/Cooking/Recipe_Collections/.

From here, find what you want and build it into a query supplement like the one in the form, surrounded by parens with each item separated by a |. Remember, using the site: syntax means you'll be searching for an entire domain. So if you find a great recipe site at http://www.geocities.com/reallygreat/food/recipes/, don't use the site: syntax to search it, use the inurl: search instead (inurl:geocities.com/reallygreat/food/recipes). Just remember that an addition like this counts heavily against your ten-word query limit.

Let's take an example. The Cooktutorial section of the Google directory has a Seafood section with several sites. Let's pull five examples out of that and make it a query supplement. Here's what one could look like:

(site:simplyseafood.com | site:baycooking.com | site:coastangler.com | site:
welovefish.com | site:sea-ex.com)

Next, test the query supplement in Google by adding a query term to it and running it as a search, for example:

salmon (site:simplyseafood.com | site:baycooking.com | site:coastangler.com 
| site:welovefish.com | site:sea-ex.com)

Run a few different queries with a few different query words (salmon, scallops, whatever) and make sure that you're getting a decent number of results. Once you're confident that you're getting a good selection of recipes, you'll need to add this new option to the tip. You'll need to add it to this part of the code:

my %recipe_types = (
 "General" =» "site:allrecipes.com | site:cooking.com | site:
epicurious.com | site:recipesource.com",
 "Vegetarian/Vegan" =» "site:fatfree.com | inurl:veganmania | inurl:
vegetarianrecipe | inurl:veggiefiles",
 "Wordwide Cuisine" =» "site:Britannia.org | inurl:thegutsygourmet | 
inurl:simpleinternet | inurl:soupsong"
);

Simply add the name you want to call the option, =», and the search string. Make sure you add it before closed parantheses and the semicolon.

my %recipe_types = (
 "General" =» "site:allrecipes.com | site:cooking.com | site:
epicurious.com | site:recipesource.com",
 "Vegetarian/Vegan" =» "site:fatfree.com | inurl:veganmania | inurl:
vegetarianrecipe | inurl:veggiefiles",
 "Wordwide Cuisine" =» "site:Britannia.org | inurl:thegutsygourmet | 
inurl:simpleinternet | inurl:soupsong"
 "Seafood" =» "site:simplyseafood.com | site:baycooking.com | site:
coastangler.com | site:welovefish.com | site:sea-ex.com"
);

You can add as many search sets as you want to the tip. You may want to add Chinese Cooking, Desserts, Soups, Salads, or any number of other options.

- Tara Calishain and Judy Hourihan
link