google-analytics - 开发脚本以从 Google Analytics 中提取数据
问题描述
我正在开发一个 Python 脚本来从 Google Analytics 中提取数据。我正在使用他们文档中的代码。
我还尝试了 Postman 和 Core Reporting API,它们正在工作
我收到此错误:
JSONDecodeError Traceback (most recent call last)
cell_name in async-def-wrapper()
cell_name in main()
<ipython-input-17-81b765f9722c> in get_service(api_name, api_version, scopes, key_file_location)
13
14 credentials = ServiceAccountCredentials.from_json_keyfile_name(
---> 15 key_file_location, scopes=scopes)
16
17 # Build the service object.
~/anaconda3/lib/python3.7/site-packages/oauth2client/service_account.py in from_json_keyfile_name(cls, filename, scopes, token_uri, revoke_uri)
218 """
219 with open(filename, 'r') as file_obj:
--> 220 client_credentials = json.load(file_obj)
221 return cls._from_parsed_json_keyfile(client_credentials, scopes,
222 token_uri=token_uri,
~/anaconda3/lib/python3.7/json/__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
294 cls=cls, object_hook=object_hook,
295 parse_float=parse_float, parse_int=parse_int,
--> 296 parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
297
298
~/anaconda3/lib/python3.7/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
346 parse_int is None and parse_float is None and
347 parse_constant is None and object_pairs_hook is None and not kw):
--> 348 return _default_decoder.decode(s)
349 if cls is None:
350 cls = JSONDecoder
~/anaconda3/lib/python3.7/json/decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):
~/anaconda3/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
解决方案
尝试使用谷歌查询资源管理器进行 curl 调用https://ga-dev-tools.appspot.com/query-explorer/
推荐阅读
- javascript - 我需要这些手工组件吗(将通过道具和条件包装器的 React.Fragment)
- mongodb - 有没有办法将 mongodb 设置为带有 vagrantfile 的服务器?
- prose - 散文降价把我的斜线变成 / 和我的双引号变成 "
- cakephp - CakePHP 3.x 搜索多个不相关的模型
- twitter-bootstrap - 在 Bootstrap4 中是一个空的
- 折叠相应的行高
- .net - 处理以前的 jwt 令牌,其中新的 jwt 令牌也为相同的凭证和安全性生成
- python - Visual Studio 2017 - python 工具
- c# - 检查 C# 查询字符串以进行 SQL 注入
- c++ - 指向数组的指针的析构函数
- c# - 在 VS2010 中将 C# 代码转换为 C++/cli 代码