笨鸟编程-零基础入门Pyhton教程

 找回密码
 立即注册

Feed 导出

发布者: 笨鸟自学网



FEEDS

2.1 新版功能.

违约: {{}}

一个字典,其中每个键都是一个feed URI(或 pathlib.Path 对象),每个值都是一个嵌套字典,其中包含特定提要的配置参数。

启用提要导出功能需要此设置。

见 存储后端 用于支持的URI方案。

例如::

{
    'items.json': {
        'format': 'json',
        'encoding': 'utf8',
        'store_empty': False,
        'item_classes': [MyItemClass1, 'myproject.items.MyItemClass2'],
        'fields': None,
        'indent': 4,
        'item_export_kwargs': {
           'export_empty_fields': True,
        },
    },
    '/home/user/documents/items.xml': {
        'format': 'xml',
        'fields': ['name', 'price'],
        'item_filter': MyCustomFilter1,
        'encoding': 'latin1',
        'indent': 8,
    },
    pathlib.Path('items.csv.gz'): {
        'format': 'csv',
        'fields': ['price', 'name'],
        'item_filter': 'myproject.filters.MyCustomFilter2',
        'postprocessing': [MyPlugin1, 'scrapy.extensions.postprocessing.GzipPlugin'],
        'gzip_compresslevel': 5,
    },
}

以下是接受的键和设置的列表,如果没有为特定的源定义提供该键,则该设置用作回退值:

  • format : serialization format .

    此设置是必需的,没有回退值。

  • batch_item_count :回到 FEED_EXPORT_BATCH_ITEM_COUNT .

    2.3.0 新版功能.

  • encoding :回到 FEED_EXPORT_ENCODING .

  • fields :回到 FEED_EXPORT_FIELDS .

  • item_classes :列表 item classes 去出口。

    如果未定义或为空,则导出所有项目。

    VERSION 新版功能.

  • item_filter :A filter class 到过滤要出口的项目。

    ItemFilter 是默认使用的。

    VERSION 新版功能.

  • indent :回到 FEED_EXPORT_INDENT .

  • item_export_kwargsdict 对应的关键字参数 item exporter class .

    2.4.0 新版功能.

  • overwrite :如果文件已存在,是否覆盖该文件 (True )或附加到其内容中 (False )

    默认值取决于 storage backend 

    • 本地文件系统: False

    • FTP: True

      注解

      某些FTP服务器可能不支持附加到文件( APPE FTP命令)。

    • S3 : True (附加 is not supported )

    • 标准输出 : False (不支持覆盖)

    2.4.0 新版功能.

  • store_empty :回到 FEED_STORE_EMPTY .

  • uri_params :回到 FEED_URI_PARAMS .

  • postprocessing :列表 plugins 用于后处理。

    插件将按照传递的列表的顺序使用。

    VERSION 新版功能.


上一篇:项目管道下一篇:请求和响应

Archiver|手机版|笨鸟自学网 ( 粤ICP备20019910号 )

GMT+8, 2024-10-18 13:26 , Processed in 0.025769 second(s), 17 queries .

© 2001-2020

返回顶部