[Python中的Google Search Console API示例脚本的JSONDecodeError

问题描述 投票:0回答:1

我正在尝试使用Search Console API查询我的Google Search Console数据。脚本为here.

我正在使用OS和python3。我在同一目录中拥有client_secret.py文件,我确定我已授权85%。

当我在另一台计算机上运行它时,它工作正常。抱歉,这种解释不会很好。我根本不知道为什么该脚本对我不起作用,但是对我的同事来说很好用。我怀疑这与我的用户/ bin文件的偶然性有关。无论如何,如果您可以查看我的查询和错误代码,也许还有更明显的东西。 (我是新来的)。

这是我的查询。我已经在129487321904不同的版本中尝试过:

$ python3 search_analytics_api_sample.py 'https://www.uselessthingstobuy.com/' '2020-02-10' '2020-03-10'

这是我的错误:

Traceback (most recent call last):
  File "search_analytics_api_sample.py", line 191, in <module>
    main(sys.argv)
  File "search_analytics_api_sample.py", line 56, in main
    scope='https://www.googleapis.com/auth/webmasters.readonly')
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/googleapiclient/sample_tools.py", line 88, in init
    client_secrets, scope=scope, message=tools.message_if_missing(client_secrets)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/client.py", line 2135, in flow_from_clientsecrets
    cache=cache)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 165, in loadfile
    return _loadfile(filename)
  File "/Users/margaretsant/anaconda3/lib/python3.7/site-packages/oauth2client/clientsecrets.py", line 122, in _loadfile
    obj = json.load(fp)
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/margaretsant/anaconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

我无法为我的生命解决这一问题。我尝试在虚拟环境中安装所有必需的软件包,但遇到相同的错误。

我也没有明显的理由拥有miniconda。在这种情况下,这可能与水蟒冲突吗?我真的不知道我在做什么,但是我需要获取此API才能为我工作。在疯狂的Google Developers文档中,我没有发现任何东西,这真令人困惑。而且,我没有找到与此脚本具有相同jsonDecoder错误的任何人。谢谢!

  • 编辑:我删除了miniconda,仍然出现相同的错误
python json google-search-api
1个回答
0
投票

非常简单,因为我在spyder中打开了client_secrets json文件,所以它自动添加了一堆关于作者的文本,这使所有内容无法正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.