Skip to content

Instantly share code, notes, and snippets.

@dwillis
Created April 14, 2009 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwillis/95350 to your computer and use it in GitHub Desktop.
Save dwillis/95350 to your computer and use it in GitHub Desktop.
An RSS feed for Romenesko's Left Rail of links and notes. RSS .91 feed.
"""
Quickly hacked script to turn Romenesko's left rail into an RSS feed. Dates don't really work.
By Derek Willis
dwillis@gmail.com
This script is in the public domain.
Dependencies: Beautiful Soup (< 3.0.7)
"""
import urllib
import datetime
from BeautifulSoup import BeautifulSoup
url = "http://www.poynter.org/column.asp?id=45"
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)
rss="""<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="0.91">
<channel>
<title>Romenesko Left Rail</title>
<link>http://www.poynter.org/column.asp?id=45</link>
<description>The other stuff</description>
<language>en-us</language>
"""
left_rail = soup.findAll('td', width='24%')[0]
items = left_rail.findAll('p')[1:]
for item in items:
if item.a["href"] == '/column.asp?id=45&aid=62012':
break
else:
url = item.a["href"]
try:
title = item.a.b.contents[0]
except:
title = item.span.contents[0]
rss+="\n<item>\n<date>%s</date><title>%s</title><link>%s</link>\n</item>\n" % (datetime.date.today(),title,url)
#close rss feed
rss+="""
</channel>
</rss>
"""
fh=open('left_rail.rss','w')
fh.write(rss)
fh.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment