LoginSignup
3
1

More than 5 years have passed since last update.

ScrapyでのJson出力を日本語にする

Last updated at Posted at 2017-11-04

問題

ScrapyでJson出力をした際に、
ターミナルでは日本語で出力されていたが、Jsonでは日本語で出力されなかったので
その時の対応したもののメモ

ターミナルの表示

{'subcategory': 'IT総合',
'title': '【動画あり】簡単操作でドリフト可能な「ドリフトスティック」がスゴい! ケン・ブロックも太鼓判',
 'url': 'https://gunosy.com/articles/RJoAa'}
2017-11-04 16:45:01 [scrapy.core.scraper] DEBUG: Scraped from <200 https://gunosy.com/categories/7>

Jsonの表示

{"title": "\u30b9\u30c8\u30ea\u30fc\u30c8\u30d5\u30fc\u30c9\u5927\u56fd\u30aa\u30e9\u30f3\u30c0\u306e\u77e5\u3089\u308c\u3056\u308bB\u7d1a\u30b0\u30eb\u30e1", "url": "https://gunosy.com/articles/a9fpc", "subcategory": "\u30b0\u30eb\u30e1\u7dcf\u5408"},

解決策

setting.pyに以下を追加すると日本語で出力できる様になります。

FEED_EXPORT_ENCODING='utf-8'
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1