#!/usr/bin/perl # noxml_google2csv.pl # Google Web Search Results via NoXML ("no xml") module # exported to CSV suitable for import into Excel # Usage: noxml_google2csv.pl "{query}" [> results.csv] # Your Google API developer's key my $google_key='insertyourkeyrighthere'; use strict; use NoXML; use Data::Dumper; $ARGV[0] or die qq{usage: perl noxml_search2csv.pl "{query}"\n}; my $google_search = new NoXML; my $results = $google_search -> doGoogleSearch( $google_key, shift @ARGV, 0, 10, "false", "", "false", "", "latin1", "latin1" ); @{$results->{'resultElements'}} or die('No results'); print Dumper(\$results); print qq{"title","url","snippet"\n}; foreach (@{$results->{'resultElements'}}) { $_->{title} =~ s!"!""!g; # double escape marks $_->{snippet} =~ s!"!""!g; my $output = qq{"$_->{title}","$_->{URL}","$_->{snippet}"\n}; $output =~ s!<.+?>!!g; # drop all html tags print $output; }