//second one i found#!/usr/bin/perl -w use strict; use SOAP::Lite; use XML::RSS; use CGI qw(:standard); use HTML::Entities (); # Set up the query term from the cgi input my $query = param("q"); my $key = param("k") || "bkasldkfjs"; # Initialise the SOAP interface my $service = SOAP::Lite -> service('http://api.google.com/GoogleSearch.wsdl'); # Run the search my $result = $service -> doGoogleSearch ($key, $query, 0, 10, "false", "", "false", "", "latin1", "latin1"); # Create the new RSS object my $rss = new XML::RSS (version => '0.91'); # Add in the RSS channel data $rss->channel( title => "Google Search for $query", link => "http://www.google.com/search?q=$query", description => "Google search for $query", language => "en", ); # Create each of the items foreach my $element (@{$result->{'resultElements'}}) { $rss->add_item( title => HTML::Entities::encode($element->{'title'}), link => HTML::Entities::encode($element->{'URL'}) ); } # print out the RSS print header('application/xml+rss'), $rss->as_string;
#!/usr/loca/bin/perl # googly.pl # usage: perl googly.pl <query> my $google_key='adfsdf'; my $google_wsdl = "./GoogleSearch.wsdl"; use strict; use SOAP::Lite; my $query = shift @ARGV or die; GoogleSearch.wsdl my $google_search = SOAP::Lite->service("file:$google_wdsl"); my $results = $google_search -> doGoogleSearch( $google_key, $query, 0, 10, "false", "", "false", "", "latin1", "latin1" ); @{$results->{resultElements}} or exit; foreach my $result (@{$results->{resultElements}}) { print join "\n", $result->{title} || "no title", $result->{URL}, $result->{snippet} || 'no snippet', "\n"; }
Edited Steve_p - added code tags and made title more searchable
In reply to Convert Google search results to RSS by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |