Thread: My linkblog has an archive. (And so should yours.)

The RSS feed for my linkblog, which goes back to December 2010, has a feature that I think no other RSS feed has (or Atom for that matter). Not only does it have an archive, but the feed itself describes the archive. It contains enough information so you could easily write a script that downloads all the content of my linkblog, in RSS.

1. If you look in the feed, look for the element. Here’s a screen shot.

2. I wrote a script that downloads the linkblog archive in full. Here’s a text file containing the script. Here’s the script as an OPML file, and as a .ftsc file. It’s written in UserTalk, but could easily be converted to other scripting languages.

2a. For fun, I pasted the script into the outline for this blog post. Let’s see if it works! 🙂

      • Courier
      • 14px
      • false
      • 115%
  • on downloadLinkblogArchive (urlFeed, folder)
    • Changes
    • local (xmltext = tcp.httpreadurl (urlfeed, 3, false))
    • xml.compile (xmltext, @xstruct)
    • scratchpad.xstruct = xstruct
    • local (adrrss = xml.getaddress (@xstruct, “rss”))
    • local (adrchannel = xml.getaddress (adrrss, “channel”))
    • local (adrarchive = xml.getaddress (adrchannel, “archive”))
    • local (urlarchive = xml.getvalue (adrarchive, “url”))
    • local (fname = xml.getvalue (adrarchive, “filename”))
    • on getdate (name)
      • local (s = xml.getvalue (adrarchive, name))
      • return (date.set (string.nthfield (s, “-“, 3), string.nthfield (s, “-“, 2), string.nthfield (s, “-“, 1), 0, 0, 0))
    • local (theday = getdate (“startDay”), endday = getdate (“endDay”))
    • loop
      • local (urlday = urlarchive + file.getdatepath (“/”, theday) + fname)
      • local (fday = folder + file.getdatepath (file.getpathchar (), theday, false) + “.xml”)
      • try
        • local (xmltext = tcp.httpreadurl (urlday, 3, false))
        • file.surefilepath (fday) //make sure all folders in path exist
        • file.writewholefile (fday, xmltext)
        • bundle //set mod and creation dates
          • local (xstruct, adrrss, adrchannel)
          • xml.compile (xmltext, @xstruct)
          • adrrss = xml.getaddress (@xstruct, “rss”)
          • adrchannel = xml.getaddress (adrrss, “channel”)
          • file.setcreated (fday, date (xml.getvalue (adrchannel, “pubDate”)))
          • file.setmodified (fday, date (xml.getvalue (adrchannel, “lastBuildDate”)))
        • msg (fday)
      • theday = date.tomorrow (theday)
      • if theday > endday
        • break
  • bundle //test code

3. I ran the script, it created a folder. Here’s a screen shot of the folder, and the folder itself as a zip archive.

4. Here are the docs for the archive element.

Hopefully that covers all the bases.


About Dave Winer

Dave Winer, 54, pioneered the development of weblogs, syndication (RSS), podcasting, outlining, and web content management software; former contributing editor at Wired Magazine, research fellow at Harvard Law School, entrepreneur, and investor in web media companies. A native New Yorker, he received a Master's in Computer Science from the University of Wisconsin, a Bachelor's in Mathematics from Tulane University and currently lives in Berkeley, California.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s