Quantcast
Channel: RSS Feed aggregator using Google App Engine - Python - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Randall for RSS Feed aggregator using Google App Engine - Python

$
0
0

I have a GAE RSS reader demo / prototype working using Feedparser - http://deliciourss.appspot.com/. Here's some code -

Fetch your feed.

data = urlfetch.fetch(feedUrl)

Parse with Feedparser

parsedData = feedparser.parse(data.content)

Change some features of the feed

    # set main section to description if empty    for ix in range(len(parsedData.entries)):        bItem = 0        if hasattr(parsedData.entries[ix],'content'):            for item in parsedData.entries[ix].content:                if item.value:                    bItem = 1                    break            if bItem == 0:                parsedData.entries[ix].content[0].value = parsedData.entries[ix].summary        else:            parsedData.entries[ix].content = [{'value':parsedData.entries[ix].summary}]

Template if you are using Django/webapp

<?xml version="1.0" encoding="utf-8"?><channel><title>{{parsedData.channel.title}}</title><url>{{feedUrl}}</url><id>{{parsedData.channel.id}}</id><updated>{{parsedData.channel.updated}}</updated>{% for entry in parsedData.entries %}<item><id>{{entry.id}}</id><title>{{entry.title}}</title><link>        {% for link in entry.links %}                {% ifequal link.rel "alternate" %}                        {{link.href|escape}}                {% endifequal %}        {% endfor %}</link><author>{{entry.author_detail.name}}</author><pubDate>{{entry.published}}</pubDate><description>{{entry.summary|escape}}</description>        {% for item in entry.content %}            {% if item.value %} <content>{{item.value|escape}}</content>            {% endif %}        {% endfor %}</item>{% endfor %}</channel>

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>