#!/usr/bin/env python # # pnu2rss by Pieter Edelman # This script converts the Physics News Update (http://www.aip.org/pnu/) to an # RSS feed. This update appears about once a week, so please choose your # update interval wisely. # # ============================================================================ # WARNING: THIS IS A STAND-ALONE SCRIPT, NOT A FILTER!! # The reason for this is that the PNU website only mentions when a new issue # has appeared. For contents an extra link should be followed. # It works with the PNU issues from 2004 onwards. # ============================================================================ # # Copyright (c) 2004 Pieter Edelman # Released under the terms of the GNU General Public License (GPL) Version 2. # See http://www.gnu.org/ for details. import urllib, re, sys # The matches used in this script: blockquote = re.compile(""); whitespace = re.compile("^\s*"); eol = re.compile("\r\n"); paragraph = re.compile("
");
tags = re.compile("<(.*?)>");
ampersand = re.compile("&");
headline = re.compile("p class=\"headline\">
statement webpage.readline(); # Append lines to the description untilis found description = ""; while (line): line = webpage.readline(); if (re.search(blockquote, line)): break; line = re.sub(whitespace, "", line); line = re.sub(eol, "", line); line = re.sub(paragraph, " \n\n
", line);
line = re.sub(ampersand, r"&", line);
line = re.sub(tags, r"<\1>", line);
description += line;
# Print out the item
print "