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


Python Settings.SEEDS_SOURCE方法代码示例

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


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

示例1: seed_loader_setup

# 需要导入模块: from frontera.settings import Settings [as 别名]
# 或者: from frontera.settings.Settings import SEEDS_SOURCE [as 别名]
    def seed_loader_setup(self, seeds_content=None):
        seed_path = os.path.join(self.tmp_path, 'seeds.txt')
        default_content = """
https://www.example.com
https://www.scrapy.org
"""
        seeds_content = seeds_content or default_content
        with open(seed_path, 'wb') as tmpl_file:
            tmpl_file.write(seeds_content.encode('utf-8'))
        assert os.path.isfile(seed_path)  # Failure of test itself
        settings = Settings()
        settings.SEEDS_SOURCE = seed_path
        crawler = type('crawler', (object,), {})
        crawler.settings = settings
        return FileSeedLoader(crawler)
开发者ID:Preetwinder,项目名称:frontera,代码行数:17,代码来源:test_seed_loader.py

示例2: setUp

# 需要导入模块: from frontera.settings import Settings [as 别名]
# 或者: from frontera.settings.Settings import SEEDS_SOURCE [as 别名]
    def setUp(self):
        self.tmp_path = mkdtemp()
        settings = Settings()
        settings.SEEDS_SOURCE = 's3://some-bucket/seeds-folder'
        settings.SEEDS_AWS_ACCESS_KEY = 'access_key'
        settings.SEEDS_AWS_SECRET_ACCESS_KEY = 'secret_key'
        crawler = type('crawler', (object,), {})
        crawler.settings = settings
        self.seed_path_1 = os.path.join(self.tmp_path, 'seeds1.txt')
        self.seed_path_2 = os.path.join(self.tmp_path, 'seeds2.txt')
        s1_content = """
https://www.example.com
https://www.scrapy.org
"""
        s2_content = """
https://www.dmoz.org
https://www.test.com
"""

        with open(self.seed_path_1, 'wb') as tmpl_file:
            tmpl_file.write(s1_content.encode('utf-8'))
        with open(self.seed_path_2, 'wb') as tmpl_file:
            tmpl_file.write(s2_content.encode('utf-8'))
        self.seed_loader = S3SeedLoader(crawler)
开发者ID:Preetwinder,项目名称:frontera,代码行数:26,代码来源:test_seed_loader.py

示例3: test_invalid_s3_seed_source

# 需要导入模块: from frontera.settings import Settings [as 别名]
# 或者: from frontera.settings.Settings import SEEDS_SOURCE [as 别名]
 def test_invalid_s3_seed_source(self):
     crawler = type('crawler', (object,), {})
     settings = Settings()
     settings.SEEDS_SOURCE = 'invalid_url'
     crawler.settings = settings
     self.assertRaises(NotConfigured, S3SeedLoader, crawler)
开发者ID:Preetwinder,项目名称:frontera,代码行数:8,代码来源:test_seed_loader.py


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