updated git and svn scripts
[xrzperl.git] / googleImage
blob75424a815718d5faa20c980b2b7dfbead76badfe
1 #!/usr/bin/perl -w
2 ###APPNAME: googleImage.pl
3 ###APPAUTHOR: duel
4 ###APPDATE: 2009-08-25 04:22:53
5 ###APPVER: 0.1
6 ###APPDESC: googleImage.pl
7 ###APPUSAGE:
8 ###APPEXAMPLE: googleImage.pl
9 ###APPOPTION:
10 use strict;
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
14 #OR nothing will work
15 use lib $ENV{XR_PERL_MODULE_DIR};
16 use URI::Escape;
17 use MyPlace::Script::Usage qw/help_required help_even_empty/;
18 #exit 0 if(help_required($0,@ARGV));
19 exit 0 if(help_even_empty($0,@ARGV));
21 my ($key,$from,$to) = @ARGV;
22 $from = 1 unless($from);
23 $to = 1 unless($to);
24 $key = uri_escape($key);
25 $key =~ s/%2B/+/i;
28 foreach my $page ($from .. $to) {
29 my $start = ($page -1) * 18;
30 my $url = 'http://www.google.com/images?hl=en&safe=off&' . "&q=$key&start=$start" . "&gbv=2&as_st=y&tbs=isch:1,isz:lt,islt:xvga&sa=N&ndsp=18";
32 open FI,"-|","wget",qw{-q -O - -e robots=off -U Mozilla/5.0},$url or die("$!\n");
33 while(<FI>) {
34 # print $_;
35 my @match = $_ =~ m/imgurl\\x3d([^\\]+)\\x26/g;
36 print $_,"\n" foreach(@match);
38 close FI;