#!/usr/bin/perl
# $Id: fetch-google-images,v 1.1 2004/04/02 12:58:02 guillaume Exp $

use Getopt::Long;
use WWW::Google::Images;
use strict;

my %opts;
my $base = 'image';
my $limit = 100;
GetOptions(
    "limit=i" => \$limit,
    "base=s"  => \$base
);

my $agent = WWW::Google::Images->new();

while (my $item = <>) {
    chomp $item;
    my $result = $agent->search($item, limit => $limit);
    if ($result) {
	mkdir($item);
	$result->save_all_contents(dir => $item, base => $base);
    }
}
