本文整理汇总了Python中article.Article.summary方法的典型用法代码示例。如果您正苦于以下问题:Python Article.summary方法的具体用法?Python Article.summary怎么用?Python Article.summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类article.Article
的用法示例。
在下文中一共展示了Article.summary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_feed
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import summary [as 别名]
def add_feed(self, feed):
"""
add_feed takes the URL or file path of a Feedzilla feed, cleans it up,
and adds the articles this Feed object's list.
"""
log.info("Retrieving feed.")
f = feedparser.parse(feed)
for item in f['entries']:
a = Article()
# Set ID as integer, without feedzilla at beginning
a.id = item['id']
a.id = re.sub(r'.*feedzilla\.com:(.*)', r'\1', a.id)
a.id = int(a.id)
if a.id not in self.articles.keys():
# Set source, author and title
a.author = item['author']
a.title = item['title']
a.source=item['source']['links'][0]['href']
a.trueSource="http://news.feedzilla.com/en_us/stories/world-news/"+str(a.id)
# Set summary, get rid of all the junk at the end
summary = item['summary']
summary = summary[:summary.find("\n\n")]
summary = summary[:summary.find("<")]
a.summary = summary
# Add the article if it doesn't already exist
self.articles[a.id] = a
示例2: save_temp_dict
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import summary [as 别名]
def save_temp_dict(self):
for k in self.newsDict:
if not self.newsDict[k]['valid']:
error = Failed(link=self.newsDict[k]['link'], title=self.newsDict[k]['title'],
post_date=self.newsDict[k]['post_date'])
error.post_time = self.newsDict[k]['post_time']
error.category = self.newsDict[k]['category']
error.summary = self.newsDict[k]['summary']
error.error_count = self.newsDict[k]['error_count'] + 1
error.save()
continue
article = Article(link=self.newsDict[k]['link'], title=self.newsDict[k]['title'],
post_date=self.newsDict[k]['post_date'])
article.post_time = self.newsDict[k]['post_time']
article.category = self.newsDict[k]['category']
article.summary = self.newsDict[k]['summary']
article.source = self.newsDict[k]['source']
article.source_link = self.newsDict[k]['source_link']
article.content = self.newsDict[k]['content']
article.image_links = self.newsDict[k]['image_links']
article.video_links = self.newsDict[k]['video_links']
article.comment_num = self.newsDict[k]['comment_num']
article.reply_num = self.newsDict[k]['reply_num']
article.save()
if self.newsDict[k]['error_count'] > 0:
Failed.objects(link=self.newsDict[k]['link']).delete()
示例3: add_feed
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import summary [as 别名]
def add_feed(self, feed):
print "Adding feed =>",
f = feedparser.parse(feed)
for item in f['entries']:
a = Article()
# Set ID as integer, without feedzilla at beginning
a.id = item['id']
a.id = re.sub(r'.*feedzilla\.com:(.*)', r'\1', a.id)
a.id = int(a.id)
if a.id not in self.articles.keys():
# Set source, author and title
a.author = item['author']
a.title = item['title']
a.source=item['source']['links'][0]['href']
a.trueSource="http://news.feedzilla.com/en_us/stories/world-news/"+str(a.id)
# Set summary, get rid of all the junk at the end
summary = item['summary']
summary = summary[:summary.find("\n\n")]
summary = summary[:summary.find("<")]
a.summary = summary
# Add the article if it doesn't already exist
self.articles[a.id] = a
print "Done"