本文整理汇总了Python中models.Feed.link方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.link方法的具体用法?Python Feed.link怎么用?Python Feed.link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.link方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_feed_from_url
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import link [as 别名]
def get_feed_from_url(url):
"""
Download a rss 2.0 feed and returns a class which represents that feed.
:param url: URL of the feed to download.
:return: Feed
"""
rss = get_rss_feed_parser(url)
if not is_rss_feed_valid(rss):
raise LookupError("Sorry! We cannot parse the rss feed. Missing required element(s).")
feed = Feed()
feed.title = rss["channel"]["title"]
feed.link = rss["channel"]["link"]
feed.description = rss["channel"]["description"]
feed.image = FeedItemImage(
url=rss["channel"]["image"]["url"],
title=rss["channel"]["image"]["title"],
link=rss["channel"]["image"]["link"],
width=rss["channel"]["image"]["width"],
height=rss["channel"]["image"]["height"],
)
feed.items = []
for item in rss["items"]:
feed.items.append(
FeedItem(
title=item["title"],
link=item["link"],
guid=item["guid"],
pub_date=datetime.fromtimestamp(mktime(item["published_parsed"])),
)
)
return feed