当前位置: 首页>>代码示例>>Python>>正文


Python Article.id方法代码示例

本文整理汇总了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
开发者ID:ledrui,项目名称:IRIS-News,代码行数:34,代码来源:feed.py

示例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"
开发者ID:rkuykendall,项目名称:iris-news,代码行数:31,代码来源:feed.py

示例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
开发者ID:janwojcik5,项目名称:GeomediaAnalyser,代码行数:19,代码来源:ArticlesFactory.py


注:本文中的article.Article.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。