【问题标题】:Setting/Configuring the output file after running scrapy spider运行scrapy spider后设置/配置输出文件
【发布时间】:2014-03-19 07:02:01
【问题描述】:

我可以从脚本中运行爬虫。但我想以 json 格式将输出存储在特定文件(比如 output.json)中。我做了很多研究,还尝试从设置中覆盖 FEED_URI 和 FEED_FORMAT。我也尝试使用 JsonItemExporter 函数,但都是徒劳的。任何帮助将不胜感激。谢谢!

【问题讨论】:

  • 你是如何运行你的蜘蛛的?请分享您的代码

标签: python json scrapy


【解决方案1】:

使用以下任一命令

scrapy crawl yourspidername --set FEED_URI=output.json --set FEED_FORMAT=json

scrapy crawl yourspidername -o output.json -t json

【讨论】:

  • 知道如何在设置中设置它(文件名+位置)吗?
【解决方案2】:

我觉得你应该用scrapy crawl yourspider -o output.json -t json

其中 -o 输出文件名和 -t 输出格式。

【讨论】:

    猜你喜欢
    • 2014-03-18
    • 2018-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-18
    • 2020-09-26
    • 2015-07-09
    • 1970-01-01
    相关资源
    最近更新 更多