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


Python Collector.get_text_from_items方法代码示例

本文整理汇总了Python中collector.Collector.get_text_from_items方法的典型用法代码示例。如果您正苦于以下问题:Python Collector.get_text_from_items方法的具体用法?Python Collector.get_text_from_items怎么用?Python Collector.get_text_from_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在collector.Collector的用法示例。


在下文中一共展示了Collector.get_text_from_items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestCollector

# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import get_text_from_items [as 别名]

#.........这里部分代码省略.........
        Add a feed.
        Print the feed.

        """
        name, url, tag = self.feed_info[0][:3]
        self.co.add_feed(name, url, tag)

        self.co.print_feed(name)

    def test_print_feeds(self):
        """ Tests print_feeds.

        Add feeds.
        print feeds.

        """
        for name, url, tag, _ in self.feed_info:
            self.co.add_feed(name, url, tag)

        self.co.print_feeds()

    def test_print_items(self):
        """ Tests print_items.

        Add a feed.
        Print items.

        """
        name, url, tag = self.feed_info[0][:3]
        self.co.add_feed(name, url, tag)

        self.co.print_items(name)

    def test_get_text_from_items(self):
        """ Tests get_text_from_items.

        Add a feed.

        For each item with "get_text_from_items" verify if: 
         1- the title is in the text.
         2- the abstract is in the text.
         3- the webpage text is in the text.

        """
        name, url, tag = self.feed_info[0][:3]
        self.co.add_feed(name, url, tag)

        for item, text in self.co.get_text_from_items(name):
            self.assertIn(item.title, text) # 1
            self.assertIn(item.abstract, text) # 2
            self.assertIn(item.webpage_text, text) # 3

    def test_get_feed(self):
        """ Tests get_feed.

        1,2- Test if get_feed retrieves the correct feed by comparing name. 
        3- Test if get_feed retrieve None for an unknown feed.

        """
        name_1, url, tag, _ = self.feed_info[0]
        feed_1_added = self.co.add_feed(name_1, url, tag)
        name_2, url, tag, _ = self.feed_info[1]
        feed_2_added = self.co.add_feed(name_2, url, tag)

        feed_1_get = self.co.get_feed(name_1)
        self.assertEquals(feed_1_get.name, feed_1_added.name) # 1
开发者ID:damiendev,项目名称:RSS-Intelligence,代码行数:70,代码来源:test.py


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