Hack 89 Create RSS 0.91 Feeds from Google

figs/moderate.gif figs/hack89.gif

A .NET program can help you create an RSS feed based on a query to Google. You have to be a registered developer at Google to use this program, but the possibilities are rich.

Peter Drayton (http://www.razorsoft.net/) has created a .NET program called google2rss that uses a Google API (http://www.google.com/apis/) query to create an RSS 0.91 feed [Hack #81] with the top 10 hits it finds on Google. You first have to go to the Google API web page to register so that you can get a license key. You cannot perform this hack without getting the license key. You will also need to install Microsoft .NET on your system. You can download .NET from Microsoft's MSDN site, http://msdn.microsoft.com/netframework/technologyinfo/howtoget/, or you can get it from http://www.gotdotnet.com. You'll need to download both the .NET Framework Version 1.1 Redistributable Package (about 24 MB) and the .NET Framework SDK Version 1.1 (about 108 MB).

Download the google2rss software from http://www.razorsoft.net/downloads/google2rss.zip. You can also read background information at http://www.razorsoft.net/weblog/stories/2002/04/13/google2rss.html.

Fortunately, the google2rss download includes source code, because after I extracted the archive, I discovered that I had to recompile the program to get it to work with .NET v1.1. That's because the binary in the archive was compiled with .NET v1.0. A copy of the recompiled program is in the file archive that is offered with the book. The compilation process has several steps, which include the .NET xsd.exe and wsdl.exe programs. These programs compile XML Schema and WSDL files into executable programs [Hack #99] that can be used by the main program. See the make file in the google2rss archive for details.

With google2rss and .NET installed, and while you are in the working directory, type the command:


You will see a long list of possible options, five of them required, ten optional, and seven default. The five required options are as follows:

-key your Google API key

Your Google account key, which you get by registering with Google as a developer.

-query query string

The subject you are querying about.

-title title of the feed

The title of the RSS 0.91 document.

-link feed's home URL

The link to where the RSS document will live.

-description feed description

A description of the feed.

Here is a sample google2rss command that queries on the term RSS:

google2rss -key "your-google-key-goes-here" -query "RSS" -safesearch true

-filter true -title "RSS on Google" -link http://www.example.com/rss

-description "Tracking RSS on Google" -outfile google.rss

You already read about the required options. The -safesearch option with a value of true screens for adult or indecent content. The -filter with true option hides similar results from the search. The -outfile sets the output filename.

The program goes out and does its query and then saves the RSS 0.91 output as google.rss, which is about 60 lines long (line length should vary from day to day and from query to query). Example 6-1 shows the RSS 0.91 document.

Example 6-1. google.rss
<?xml version="1.0" encoding="utf-8"?>

<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/

XMLSchema-instance" version="0.91">


    <title>RSS on Google</title>


    <description>Tracking RSS on Google</description>


    <lastBuildDate>Thu, 08 Apr 2004 00:38:27 GMT</lastBuildDate>


      <title>&lt;b&gt;RSS&lt;/b&gt; 2.0 Specification</title>

      <description>Technology at Harvard Law. Internet technology 

hosted by Berkman Center. &lt;b&gt;RSS&lt;/b&gt; 2.0&lt;br&gt; 

Specification. Contents. &lt;b&gt;...&lt;/b&gt; is &lt;b&gt;RSS&lt;

/b&gt;? &lt;b&gt;RSS&lt;/b&gt; Directory. About this website. 

Specifications. &lt;b&gt;...&lt;/b&gt;  </description>




      <title>XML.com: What is &lt;b&gt;RSS&lt;/b&gt;? [Dec. 18, 2002]


      <description>In Mark Pilgrim&amp;#39;s inaugural Dive Into XML 

column, he reviews the history&lt;br&gt; and technical details of the 

varieties of &lt;b&gt;RSS&lt;/b&gt; on the Web. &lt;b&gt;...&lt;/b&gt;

 What is &lt;b&gt;RSS&lt;/b&gt;? &lt;b&gt;...&lt;/b&gt; </description>





      <title>RDF Site Summary (&lt;b&gt;RSS&lt;/b&gt;) 1.0</title>

      <description>RDF Site Summary (&lt;b&gt;RSS&lt;/b&gt;) 1.0. 

Official Specification. The &lt;b&gt;RSS&lt;/b&gt; 1.0 specification

&lt;br&gt; was released on 2000-12-06. It was published &lt;b&gt;...

&lt;/b&gt;  </description>




      <title>RDF Site Summary (&lt;b&gt;RSS&lt;/b&gt;) 1.0</title>

      <description>RDF Site Summary (&lt;b&gt;RSS&lt;/b&gt;) 1.0. 

Abstract. RDF Site Summary (&lt;b&gt;RSS&lt;/b&gt;) is a lightweight

&lt;br&gt; multipurpose extensible metadata description and 

syndication format. &lt;b&gt;...&lt;/b&gt;  </description>




      <title>Introduction to &lt;b&gt;RSS&lt;/b&gt; - 


      <description>Introduction to &lt;b&gt;RSS&lt;/b&gt;. &lt;b&gt;

...&lt;/b&gt; Then you need an &lt;b&gt;RSS&lt;/b&gt; news feed. To 

start all you need&lt;br&gt; is content you want broadcast, and one &lt;b&

gt;RSS&lt;/b&gt; text file. What is &lt;b&gt;RSS&lt;/b&gt;? 

&lt;b&gt;...&lt;/b&gt;  </description>





      <title>Feed Validator for Atom and &lt;b&gt;RSS&lt;/b&gt;


      <description>FEED Validator. for Atom and 

&lt;b&gt;RSS&lt;/b&gt;. Jump to&lt;br&gt; navigation. Now supports 

Atom 0.3! (more). &lt;b&gt;...&lt;/b&gt;  </description>




      <title>Feedster :: &lt;b&gt;RSS&lt;/b&gt; Search Engine</title>

      <description>Feedster, the fast search engine for &lt;b&gt;RSS

&lt;/b&gt; content including weblogs,&lt;br&gt; now with myFeedster, 

your custom web-based newsreader. Feedster. &lt;b&gt;...&lt;/b&gt;  





      <title>Latest &lt;b&gt;RSS&lt;/b&gt; News (&lt;b&gt;RSS&lt;/b&gt; Info)


      <description>The &lt;b&gt;RSS&lt;/b&gt; format allows quick and 

easy syndication of news, headlines, and more. &lt;b&gt;...&lt;/

b&gt; &lt;b&gt;RSS&lt;/b&gt;&lt;br&gt; Info. News and 

information on the &lt;b&gt;RSS&lt;/b&gt; format. News. Readers. Tools. 

Resources. &lt;b&gt;...&lt;/b&gt;  </description>




      <title>&lt;b&gt;RSS&lt;/b&gt; 0.92</title>

      <description> &lt;b&gt;...&lt;/b&gt; &lt;b&gt;RSS&lt;/b&gt; 

0.92. Mon, Dec 25, 2000; by Dave Winer. New version available, 

October&lt;br&gt; 2002 &lt;b&gt;RSS&lt;/b&gt; 2.0 is the current 

version. It is upward compatible &lt;b&gt;...&lt;/b&gt;  





      <title>&lt;b&gt;RSS&lt;/b&gt; Tutorial for Content Publishers 

and Webmasters</title>

      <description>&lt;b&gt;RSS&lt;/b&gt; Tutorial. for Content 

Publishers and Webmasters. This tutorial explains&lt;br&gt; the 

features and &lt;b&gt;...&lt;/b&gt; Introducing &lt;b&gt;RSS&lt;/b&gt;. 

Think about all of the information &lt;b&gt;...&lt;/b&gt;  






Now play around with the options the program offers, saving your result in a different file each time.