本文整理汇总了Python中article.Article.trueSource方法的典型用法代码示例。如果您正苦于以下问题:Python Article.trueSource方法的具体用法?Python Article.trueSource怎么用?Python Article.trueSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类article.Article
的用法示例。
在下文中一共展示了Article.trueSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_feed
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import trueSource [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: add_feed
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import trueSource [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"