Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've seen lots of google searches 2 rss converters - they all seem to be web-based cgi scripts though, plus I'm having a problem with XML::RSS even though I installed it and SOAP::Lite through cpan. What is wsdl or wdsl or whatever it's supposed to be? anyone have a succesful script? I also want to add the 10-limit loop from Google Hacks and the permuter too, then feed it to a diff.
#!/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;
//second one i found
#!/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

Replies are listed 'Best First'.
Re: Convert Google search results to RSS
by Aristotle (Chancellor) on Sep 07, 2004 at 01:22 UTC

    WSDL is <q>Web Services Description Language (XML format for describing network services)</q>, as Acronymfinder helpfully reveals.

    The code would be much simpler if you let Net::Google handle the SOAP stuff for you.

    As far as you XML::RSS problems are concerned, we can't help you if you don't tell us what doesn't work.

    Makeshifts last the longest.

Re: Convert Google search results to RSS
by johnnywang (Priest) on Sep 06, 2004 at 19:25 UTC
    Please use <code> </code>around your code, it's easier on the eyes. Thanks.