Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: Google Trends

__/ [ Doc O'Leary ] on Saturday 13 May 2006 23:18 \__

> In article <1484061.v58VQED4Pe@xxxxxxxxxxxxxxx>,
>  Roy Schestowitz <newsgroups@xxxxxxxxxxxxxxx> wrote:
> 
>> __/ [ Doc O'Leary ] on Friday 12 May 2006 20:54 \__
>> 
>> > Notice that I added "mac os x" myself, and it completely dwarfs the
>> > things Suggest was feeding up.  I have no idea what algorithm Suggest
>> > uses, but it clearly isn't based directly on what people are searching
>> > for. ... [par broken]
>> 
>> 
>> No,  it  is based on the number of results.
> 
> No, it isn't.  Again, you haven't even bothered to look at the evidence
> before posting.  The biggest completion results I see for "mac " is 15
> million, but "mac help" completes at over 25 million and is not in that
> initial listing.  Suggest is just plain broken, and it is a mistake to
> recommend it over Trends at this point.
 
No, it is just **well** out-of-date. See my previous message. I have been
watching the numbers carefully for over a year (it's a script). No changes.

,----[ Code ]
| # gsuggest.pl - Google suggest
| #
| # (c) 2004 By John Bokma, http://johnbokma.com/
| 
| use strict;
| use warnings;
| 
| use URI::Escape;
| use LWP::UserAgent;
| 
| 
| unless ( @ARGV ) {
| 
|     print "usage: gsuggest.pl query\n";
|     exit( 1 );
| }
| 
| my $url = 'http://www.google.com/complete/search?js=true&qu=' .
|     uri_escape( join ' ' => @ARGV );
| 
| my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0' );
| my $response = $ua->get( $url );
| 
| $response->is_success or
|     die "$url: ", $response->status_line;
| 
| my $content = $response->content;
| 
| # extract the information from the JavaScript file response
| # note that the first " and the last " in the Arrays are
| # excluded (if data is present)
| my ( $element, $array1, $array2 ) = $content =~
|     /"(.+?)".+?Array\("(.+?)"\).+?Array\("(.+?)"\)/;
| 
| unless ( defined $array1 ) {
| 
|     print "No results\n";
|     exit;
| }
| 
| # split the first "array" on the item separator (the very first "
| # and the very last " are already removed)
| my @suggestions = split /", "/, $array1;
| 
| # remove the result(s) string from the number of results
| # remove &nbsp; if present (no results known)
| # and split the second "array"
| # note that a negative limit is used to catch trailing empty
| # results (caused by removing &nbsp;)
| $array2 =~ s/ results?//g;
| $array2 =~ s/&nbsp;//g;
| my @results = split /", "/, $array2, -1;
| 
| # make suggestion => result(s) pairs.
| # note that the number of results is turned into a right justified string
| my @pairs = map { [ sprintf ( "%12s", shift @results ) => $_ ] }
| @suggestions;
| 
| # print the pairs in suggested order
| print "@$_\n" for @pairs;
| 
| # print the pairs sorted on the number of results for each suggestion,
| # largest "number" first since the numbers are right justified strings.
| print "\nsorted:\n";
| print "@$_\n" for sort { $b->[0] cmp $a->[0] } @pairs;
`----

Best wishes,

Roy

-- 
Roy S. Schestowitz      | "Nothing to see in this sig, please move along"
http://Schestowitz.com  |  SuSE GNU/Linux   ¦     PGP-Key: 0x74572E8E
  7:45am  up 16 days 14:42,  12 users,  load average: 0.51, 0.38, 0.41
      http://iuron.com - help build a non-profit search engine

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index