Skip to Main Content
Developing Feeds with RSS and Atom
book

Developing Feeds with RSS and Atom

by Ben Hammersley
April 2005
Intermediate to advanced content levelIntermediate to advanced
270 pages
7h 13m
English
O'Reilly Media, Inc.
Content preview from Developing Feeds with RSS and Atom

Google to RSS with SOAP

Google, the search engine of fashion these days, is as close to an authority as you can get on the Internet. If it’s not mentioned on Google, the feeling is, it’s not really online. And if it is, conversely, then people will find it. Keeping track of things in Google’s database, therefore, is an important job. Whether you are trying to find things out or monitoring for other people’s discoveries, an RSS feed is the perfect way to do it. Happily, Google provides a nice interface to work with its systems. This makes things very easy.

Walking Through the Code

We start, as ever, with the usual pragmas, CGI and XML::RSS. This time, you also need SOAP::Lite and HTML::Entitie.

use warnings;
use strict;
use XML::RSS;
use CGI qw(:standard);
use HTML::Entities ( );
use SOAP::Lite;

We’ll set up the query term, and the Google API key, from the CGI input. Then, we fire up the SOAP::Lite by pointing it at Google’s WSDL file. WSDL files contain the finer details of a SOAP interface, telling the script exactly where to send commands and so on.

my $query = param("q");
my $key   = param("k");

my $service = SOAP::Lite -> service('http://api.google.com/GoogleSearch.wsdl');

Now, run the search using the SOAP interface we just set up; then set up the feed:

my $result = $service -> doGoogleSearch ($key, $query, 0, 10, "false", "", "false","", "latin1", "latin1"); my $rss = new XML::RSS (version => '2.00'); $rss->channel( title => "Google Search for $query", link => "http://www.google.com/search?q=$query", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How to Build an RSS 2.0 Feed

How to Build an RSS 2.0 Feed

Mark Woodman
Secrets of RSS

Secrets of RSS

Steven Holzner

Publisher Resources

ISBN: 0596008813Supplemental ContentErrata Page