scrapy 有没有办法在不使用 -o -t 参数的情况下打印 json 文件 [英] scrapy is there a way to print json file without using -o -t parameters

查看:39
本文介绍了scrapy 有没有办法在不使用 -o -t 参数的情况下打印 json 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常这样称呼我的蜘蛛:

I am usually calling my spider like this:

scrapy crawl Spider -o fileName -t json

并且我在 fileName 文件中以 json 格式打印了正确的数据.

and I got the correct data printed in the fileName file as json formated.

现在我想这样称呼我的蜘蛛:

Now I want to call my spider like this:

scrapy crawl Spider

我的问题

有没有办法在不使用 -o -t 参数的情况下将输出打印到文件中?

my question

is there a way to print the output to a file without using the -o -t parameters?

推荐答案

是的,可以做到.将此添加到您的设置中

Yes it can be done. add this to your settings

FEED_EXPORTERS = {
 'jsonlines': 'scrapy.contrib.exporter.JsonLinesItemExporter',
}
FEED_FORMAT = 'jsonlines'
FEED_URI = "NAME_OF_FILE.json"

供参考

http://doc.scrapy.org/en/latest/topics/feed-exports.html

这篇关于scrapy 有没有办法在不使用 -o -t 参数的情况下打印 json 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆