0

我正在使用 anaconda 从我的 json.gz 文件中仅选择一些字段,使用-

shodan parse --fields port,isp,hostnames,location,timestamp,org,domain,transport,vulns,ssl,http.server,ip_str --separator , shodan-export.json.gz > shodan-export-proc.json.gz

我一直收到这个错误 -

(base) C:\Users\me>shodan parse --fields ip,port,isp,hostnames,location,timestamp,org,domain,transport,vulns,ssl,http.server,ip_str --separator , shodan-export.json.gz > shodan-export-proc.json.gz
Traceback (most recent call last):
  File "D:\Software\Anaconda\Scripts\shodan-script.py", line 11, in <module>
    load_entry_point('shodan==1.11.1', 'console_scripts', 'shodan')()
  File "D:\Software\Anaconda\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "D:\Software\Anaconda\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "D:\Software\Anaconda\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\Software\Anaconda\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\Software\Anaconda\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "D:\Software\Anaconda\lib\site-packages\shodan-1.11.1-py3.7.egg\shodan\__main__.py", line 360, in parse
  File "D:\Software\Anaconda\lib\site-packages\click\utils.py", line 260, in echo
    file.write(message)
  File "D:\Software\Anaconda\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 3627-3628: character maps to <undefined>

我遇到了这个 GitHub 问题,并且相信我在转换文件时需要使用 utf-8 编码;但是对于 Shodan/Anaconda,我该怎么做呢?

https://github.com/achillean/shodan-python/issues/34

4

1 回答 1

0

在 Anaconda- 键入以下内容,它将起作用-

chcp 65001
set PYTHONIOENCODING=utf-8
于 2019-04-11T16:59:20.520 回答