Google Hacks Free Open Book

Google Hacks

Previous Section Next Section

Hack 85 Instant Messaging Google

figs/expert.giffigs/hack85.gif

Accessing Google with AOL Instant Messenger.

If we're going to step out beyond the Google interface, why even bother to use the Web at all? The Google API makes it possible to access Google's information in many different ways. Googlematic makes it possible to query Google from the comfort of AOL Instant Messenger.

Here's how it works: send a message (a Google query) to the instant messenger buddy, "googlematic." Googlematic will message you back with the top result for your query. Reply with "More" and you'll get more results formatted as a numbered list. Figure 6-22 illustrates this.

Figure 6-22. Query to googlematic through AOL Instant Messenger
figs/gooH_0622.gif

Message with the number associated with a particular result for further details, as shown in Figure 6-23.

Figure 6-23. Requesting further detail for a googlematic result
figs/gooH_0623.gif

The Googlematic script, further instructions, and links to required modules may be found at http://interconnected.org/googlematic/.

85.1 The Code

#!/usr/bin/perl -w
# googlematic.pl
# Provides an AIM interface to Google, using the Google SOAP API
# and POE to manage all the activity.
#
# Usage
# ./googlematic.pl &
#
# Requirements
# - Googlematic::IM, Googlematic::Responder, Googlematic::Search,
#   which are all distributed with this script
# - CGI
# - HTML::Entities
# - Net::AOLIM
# - POE
# - SOAP::Lite
# - XML::Parser
#
# Essential configuration (below)
# - AIM username and password (used in Googlematic::IM)
# - Google API Developer Key (used in Googlematic::Search)
#
# Optional configuration (below)
# - Search request throttling (used in Googlematic::Search)
# - Limit of number of user sessions open (used in Googlematic::IM)
# - Time limit on a user session (used in Googlematic::Responder)
#
# (c) 2002 Matt Webb <matt@interconnected.org> All rights reserved

use strict;
use POE;

$| = 1;

use Googlematic::IM;
use Googlematic::Search;

# Configuration variables
$Googlematic::CONFIG = {
  aim_username => "xxxxxxx",
  aim_password => "xxxxxxx",
  google_key   => "your key goes here",
  searches_per_hour => "35", # the Google limit is 1000/day
  max_user_sessions => "5",
  user_session_timeout => "120" # in seconds
};

# There are two POE sessions:
# 1 - Googlematic::IM, known as 'im', takes care of the Instant Messager
#     connection and looks after user sessions (which are created as new
#     POE sessions, and known as Responders).
POE::Session->create(
  package_states => [
    Googlematic::IM => [
      '_start', 'login_aim', 'loop', 'spawner',
      'handler_aim', 'send', '_child', '_stop', 'proxy'
    ]
  ]
);

# 2 - Googlematic::Search, known as 'google', takes care the SOAP::Lite
#     object making the searches on Google. Requests to it are sent from the
#     individual Responders.
POE::Session->create(
  package_states => [
    Googlematic::Search => [
      '_start', 'loop', 'search', 'reset'
    ]
  ]
);

# Run the POE machine.
$poe_kernel->run(  );

exit;

—Tara Calishain and Matt Webb

    Previous Section Next Section


         Main Menu
    Main Page
    Table of content
    Copyright
    Dedication
    Credits
    Foreword
    Preface
    Chapter 1. Searching Google
    Chapter 2. Google Special Services and Collections
    Chapter 3. Third-Party Google Services
    Chapter 4. Non-API Google Applications
    Chapter 5. Introducing the Google Web API
    Chapter 6. Google Web API Applications
    6.1 Hacks #60-85
    6.2 The Ingenuity of Millions
    6.3 Learning to Code
    6.4 What You'll Find Here
    6.5 Finding More Google API Applications
    6.6 The Possibilities Aren't Endless, but They're Expanding
    Hack 60 Date-Range Searching with a Client-Side Application
    Hack 61 Adding a Little Google to Your Word
    Hack 62 Permuting a Query
    Hack 63 Tracking Result Counts over Time
    Hack 64 Visualizing Google Results
    Hack 65 Meandering Your Google Neighborhood
    Hack 66 Running a Google Popularity Contest
    Hack 67 Building a Google Box
    Hack 68 Capturing a Moment in Time
    Hack 69 Feeling Really Lucky
    Hack 70 Gleaning Phonebook Stats
    Hack 71 Performing Proximity Searches
    Hack 72 Blending the Google and Amazon Web Services
    Hack 73 Getting Random Results (On Purpose)
    Hack 74 Restricting Searches to Top-Level Results
    Hack 75 Searching for Special Characters
    Hack 76 Digging Deeper into Sites
    Hack 77 Summarizing Results by Domain
    Hack 78 Scraping Yahoo! Buzz for a Google Search
    Hack 79 Measuring Google Mindshare
    Hack 80 Comparing Google Results with Those of Other Search Engines
    Hack 81 SafeSearch Certifying URLs
    Hack 82 Syndicating Google Search Results
    Hack 83 Searching Google Topics
    Hack 84 Finding the Largest Page
    Hack 85 Instant Messaging Google
    Chapter 7. Google Pranks and Games
    Chapter 8. The Webmaster Side of Google
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele