/[perlscripts]/googlism
ViewVC logotype

Contents of /googlism

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Mon Feb 14 06:31:16 2005 UTC (12 years, 7 months ago) by jaldhar
File size: 1971 byte(s)
Initial import.
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use LWP::UserAgent;
5
6 my $input = join ' ', @ARGV;
7
8 $input =~ /(who|what|where|when)\s*(is)?\s*(\w+)/i;
9 my $type = $1;
10 my $ism = $3;
11
12 unless ($ism)
13 {
14 die "Must specify a term to search for.\n";
15 }
16
17
18 if ($type =~ /who/i)
19 {
20 $type = 1;
21 }
22 elsif ($type =~ /what/i)
23 {
24 $type = 2;
25 }
26 elsif ($type =~ /where/i)
27 {
28 $type = 3;
29 }
30 elsif ($type =~ /when/i)
31 {
32 $type = 4;
33 }
34 else
35 {
36 die "Unknown query type! Should be: who, what, where, or when.\n";
37 }
38
39 my $ua = LWP::UserAgent->new();
40 my $response = $ua->post('http://www.googlism.com/index.htm',
41 { ism => $ism, type => $type }, );
42
43 unless($response->is_success)
44 {
45 die "$response->status_line\n";
46 }
47
48 my $googlism = $response->content;
49
50 while ($googlism =~ /($ism is.+)<br>/g)
51 {
52 print "$1\n";
53 }
54
55 __END__
56
57 =pod
58
59 =head1 NAME
60
61 googlism -- Query www.googlism.com
62
63 =head1 SYNOPSIS
64
65 B<googlism who|what|where|when [is] searchterm >
66
67 =head1 DESCRIPTION
68
69 Googlism was created as a fun tool to see what Google "thinks" of certain
70 topics and people. Of course, the results are not really Google's opinion,
71 they're yours, the web site owners of the world. Within the Google results are
72 thousands of your thoughts and opinions about thousands of different topics
73 and people, we simply search Google and let you know what website owners think
74 about the name or topic you suggested.
75
76 This script lets you query www.googlism.com and formats the results of your
77 query in RSS 0.91 XML format. You can then postprocess this in various ways
78 such as converting it to HTML to add to your web site.
79
80 =head1 INSTALLATION
81
82 Make the script executable. You will also need the B<LWP>, and B<XML::RSS>
83 packages from CPAN.
84
85 =head1 SEE ALSO
86
87 L<http://www.googlism.com/>
88
89 =head1 AUTHOR
90
91 Jaldhar H. Vyas E<lt>jaldhar@braincells.comE<gt>
92
93 =head1 LICENSE
94
95 This code is free software under the Crowley Public License ("Do what
96 thou wilt shall be the whole of the license")
97
98 =head1 VERSION
99
100 1.0 -- Nov 10, 2002
101
102 =cut

Properties

Name Value
svn:executable

webmaster@braincells.com
ViewVC Help
Powered by ViewVC 1.1.26