本文整理汇总了Python中models.Feed.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.parse方法的具体用法?Python Feed.parse怎么用?Python Feed.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.parse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feed_register
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import parse [as 别名]
def feed_register (feed_url, user_id):
feed_new = False
#app.logger.info ("RSS LINK = " + feed_url)
feed = dboper.get_feed_by_rsslink(feed_url) #Check if it's already in the central repository
if not feed: ## New feed in the repository
feed_new = True
d = Feed.parse(feed_url)
#app.logger.info(d.feed)
if 'image' in d.feed:
imgurl = d.feed.image.href
else:
imgurl = None
if 'link' in d.feed:
sitelink = d.feed.link
else:
sitelink = None
feed = Feed (name=d.feed.title, rsslink=feed_url, image_url=imgurl, sitelink=sitelink)
dboper.add_feed(feed) #Add new feed to the repository (if not exist)
#app.logger.info("NEW FEED: " + feed.name)
dboper.add_user_feed_by_id(user_id, feed) #By user_id and not g.user because g object is lost in another thread
#app.logger.info("ADDING NEW USER FEED: " + feed.name)
#if feed_new: #If completely new, load articles
app.logger.info("LOADING ARTICLES " )
n = dboper.load_new_user_articles(feed, user_id)
app.logger.info("Fetched: " + str(n))