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


In reply to Convert Google search results to RSS by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.