鱼C论坛

 找回密码
 立即注册
查看: 980|回复: 1

请问57课scrapy -t json是什么意思

[复制链接]
发表于 2019-1-22 16:24:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
小甲鱼老师第57课用了
scrapy crawl dmoz -o items.json -t json
根据python英文文档,scrapy crawl myspider -o items.json是dump into a JSON file(转储到JSON文件中)
也就是说前半句可以理解
尝试了一下单独 scrapy crawl dmoz -o items.json也可以保存文件
那后半句-t json到底有什么用
如果我单纯把这句话改成 scrapy crawl dmoz -o items.json -t gay
会提示我
crawl: error: Unrecognized output format 'gay', set one using the '-t' switch or as a file extension from the supported list ('json', 'jsonlines', 'jl', 'csv', 'xml', 'marshal', 'pickle')
也就是说-t后面的格式只能是这几个当中之一
但是我改成-t csv出来的还是叫json的文件,那请问-t是干吗用的啊
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-1-23 00:34:28 | 显示全部楼层
-t 是转换输出文件的格式
  1. $ scrapy crawl -h
  2. Usage
  3. =====
  4.   scrapy crawl [options] <spider>

  5. Run a spider

  6. Options
  7. =======
  8. --help, -h              show this help message and exit
  9. -a NAME=VALUE           set spider argument (may be repeated)
  10. --output=FILE, -o FILE  dump scraped items into FILE (use - for stdout)
  11. --output-format=FORMAT, -t FORMAT
  12.                         format to use for dumping items with -o

  13. Global Options
  14. --------------
  15. --logfile=FILE          log file. if omitted stderr will be used
  16. --loglevel=LEVEL, -L LEVEL
  17.                         log level (default: DEBUG)
  18. --nolog                 disable logging completely
  19. --profile=FILE          write python cProfile stats to FILE
  20. --pidfile=FILE          write process ID to FILE
  21. --set=NAME=VALUE, -s NAME=VALUE
  22.                         set/override setting (may be repeated)
  23. --pdb                   enable pdb on failure
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-13 14:55

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表