我正在通过Python3试用Google Analytics APi v4。我要查询30多个查询。据我了解,我只能通过report.batchGet()一次请求5个查询。
所以我已经将请求函数放在for循环中,该循环给出了
错误:元组索引超出了httplib2范围。
但是,如果我一次手动调用每个查询的请求(一次5个),我将能够获得响应,而不会出现任何错误。将其放入循环会产生错误。请帮忙!
来自以下位置的代码:{https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py
findElement
上面的代码不起作用!为什么呢
编辑: 错误是:
def get_report(analytics,arguements):
"""Queries the Analytics Reporting API V4.
Args:
analytics: An authorized Analytics Reporting API V4 service object.
Returns:
The Analytics Reporting API V4 response.
"""
return analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
'metrics': [{'expression': 'ga:sessions'}],
'dimensions': [{'name': 'ga:country'}]
},{...},{...},{...}] # Assume batched request
}
).execute()
for loop
# Assume I changed the query by passing arguements
response = get_report(analytics,arguements)