scrapy 2.3 序列化格式

2021-06-09 10:01 更新

為了序列化 爬取 的數(shù)據(jù),提要導(dǎo)出使用 Item exporters . 開箱即用支持這些格式:

  • JSON
  • 杰森線
  • CSV
  • XML

但是您也可以通過 ?FEED_EXPORTERS? 設(shè)置。

JSON

  • 價(jià)值 ?format? 關(guān)鍵在 ?FEEDS? 設(shè)置:json ?
  • 出口商:?JsonItemExporter ?
  • 見 this warning 如果您使用的是大型提要的JSON。

杰森線

  • 價(jià)值 ?format? 關(guān)鍵在 ?FEEDS? 設(shè)置: ?jsonlines ?
  • 出口商: ?JsonLinesItemExporter?

CSV

  • 價(jià)值 ?format? 關(guān)鍵在 ?FEEDS? 設(shè)置: ?csv ?
  • 出口商: ?CsvItemExporter ?
  • 指定要導(dǎo)出的列及其順序的步驟使用 ?FEED_EXPORT_FIELDS? . 其他feed導(dǎo)出器也可以使用此選項(xiàng),但對(duì)于csv很重要,因?yàn)榕c許多其他導(dǎo)出格式不同,csv使用固定頭。

XML

  • 價(jià)值 ?format? 關(guān)鍵在 ?FEEDS? 設(shè)置: ?xml ?
  • 出口商: ?XmlItemExporter?

泡菜

  • 價(jià)值 ?format? 關(guān)鍵在 ?FEEDS? 設(shè)置: ?pickle ?
  • 出口商: ?PickleItemExporter ?

元帥

  • 價(jià)值 ?format? 關(guān)鍵在 ?FEEDS? 設(shè)置: ?marshal ?
  • 出口商: ?MarshalItemExporter?

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)