【问题标题】:JSONDecodeError for Google Search Console API sample script in PythonPython 中 Google Search Console API 示例脚本的 JSONDecodeError
【发布时间】:2020-04-06 19:29:45
【问题描述】:

我正在尝试使用 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。在这种情况下,这可能与 anaconda 冲突吗?我真的不知道我在做什么,但我需要让这个 API 为我工作。我没有在疯狂的 Google Developers 文档中找到任何东西,这太令人困惑了。而且,我还没有找到任何对此脚本有相同 jsonDecoder 错误的人。谢谢!

  • 编辑:我删除了 miniconda,仍然出现同样的错误

【问题讨论】:

    标签: python json google-search-api


    【解决方案1】:

    所以,真的很简单,因为我在 spyder 中打开了我的 client_secrets json 文件,它自动添加了一堆关于作者的文本,这导致一切都不起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多