Ejemplo n.º 1
0
def update_feed(profile, provider, rss_url):

    Content.objects.filter(user=profile.user, provider=provider).delete()

    print rss_url
    feed = feedparser.parse(rss_url)
    for entry in feed.get("entries")[:10]:
        content = Content()
        content.user = profile.user
        content.provider = provider
        content.title = entry.title
        content.link = entry.link
        content.date = dateutil_parse(getattr(entry, "published", entry.updated))
        content.mime_type, content.body = get_body_and_mime_type(entry)
        if content.mime_type == "text/html":
            content.body = santize_and_hightlight_html(content.body)
        content.save()
Ejemplo n.º 2
0
def update_feed(profile, provider, rss_url):

    Content.objects.filter(user=profile.user, provider=provider).delete()

    print rss_url
    feed = feedparser.parse(rss_url)
    for entry in feed.get('entries')[:10]:
        content = Content()
        content.user = profile.user
        content.provider = provider
        content.title = entry.title
        content.link = entry.link
        content.date = dateutil_parse(
            getattr(entry, 'published', entry.updated))
        content.mime_type, content.body = get_body_and_mime_type(entry)
        if content.mime_type == 'text/html':
            content.body = santize_and_hightlight_html(content.body)
        content.save()