add rss proxy

This commit is contained in:
hillerliao
2022-05-15 17:11:42 +08:00
parent 16c001c300
commit a22c3d6773
5 changed files with 128 additions and 41 deletions

View File

@@ -0,0 +1,34 @@
import requests
import feedparser
from rsshub.utils import DEFAULT_HEADERS
from rsshub.utils import fetch
def parse(post):
item = {}
item['title'] = post.title
item['description'] = post.summary
item['pubDate'] = post.published
item['link'] = post.link
return item
def ctx(feed_url=''):
# tree = fetch(feed_url,headers=DEFAULT_HEADERS)
# title = tree.css('channel').css('title::text').get()
# description = tree.css('channel').css('description').get()
# posts = tree.css('item')
feed = feedparser.parse(feed_url)
title = feed.feed.title
description = feed.feed.subtitle
posts = feed.entries
return {
'title': title,
'link': feed_url,
'description': description,
'author': feed.feed.author,
'items': list(map(parse, posts))
}