本文整理汇总了Python中article.Article.id方法的典型用法代码示例。如果您正苦于以下问题:Python Article.id方法的具体用法?Python Article.id怎么用?Python Article.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类article.Article
的用法示例。
在下文中一共展示了Article.id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_feed
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import id [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 id [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"
示例3: single_parsed_directory
# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import id [as 别名]
def single_parsed_directory(parsed_articles_file):
articles = []
print("Parsing " + parsed_articles_file)
feed_file = open(parsed_articles_file, "r")
lines = feed_file.readlines()
for line in lines[1:]:
parts = line.split('\t')
article = Article()
article.id = parts[0]
article.feed = parts[1]
article.time = parts[2]
article.title = parts[3]
article.text = parts[4]
article.add_tag(parts[5].replace("\"", ""))
articles.append(article)
feed_file.close()
return articles