-
Notifications
You must be signed in to change notification settings - Fork 0
/
googlerss.cgi
38 lines (31 loc) · 1.12 KB
/
googlerss.cgi
1
2
#!/usr/bin/perl -wuse strict;use SOAP::Lite;use XML::RSS;use CGI qw(:standard);use HTML::Entities ();# Set up the query term from the cgi inputmy $query = param("q");my $key = param("k") || "I2ZLf3I0K07Vf1zfOeEUf/P7r4r6t0bR";
# Initialise the SOAP interfacemy $service = SOAP::Lite -> service('http://api.google.com/GoogleSearch.wsdl');# Run the searchmy $result = $service -> doGoogleSearch ($key, $query, 0, 10, "false", "", "false","", "latin1", "latin1");# Create the new RSS objectmy $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 itemsforeach my $element (@{$result->{'resultElements'}}) { $rss->add_item( title => HTML::Entities::encode($element->{'title'}), link => HTML::Entities::encode($element->{'URL'}) ); }# print out the RSSprint header('application/xml+rss'), $rss->as_string;