有没有一种方法可以批量更新配置文件(ViewID)查询?

2024-09-28 21:41:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在努力使我们机构的分析达到最佳实践,这将需要批量更新,创建和修改几个分析视图ID。你知道吗

我不用手动更新分析中的每个视图,而是通过google分析的管理api更新了相当数量的视图。你知道吗

我遇到的问题是,写配额限制被设置为每天50个,按照这个速度,仅仅更新viewids就需要27天,谁知道我需要做的其他事情要花多长时间。你知道吗

对于这个特殊的问题,我进行了单独的查询来更新viewid,但是很快就达到了每日的写入配额。你知道吗

我目前正在使用googleapi库中的BatchHttpRequest对我的查询进行批处理,但是查询发生得很快,而且看起来并没有减少正在发生的查询的数量。你知道吗

https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.http.BatchHttpRequest-class.html

我正在尝试这种方法,因为这是一种在管理用户时减少查询的推荐方法,我希望我可以看到数据的类似性能提升。你知道吗

https://developers.google.com/analytics/devguides/config/mgmt/v3/user-management#batching

batch = BatchHttpRequest(callback=call_back)

    #for every item in list put together update query
    for i in range(1, max_row+1):

        link = service.management().profiles().update(
            accountId=accountid,
            webPropertyId=propertyid,
            profileId=viewid,
            body={
                'name': 'Master View',
                'eCommerceTracking': True,
                'enhancedECommerceTracking': True,
                'currency': 'USD',
                'timezone': 'America/New_York',
                'websiteUrl': updatesite
            }
        )

        #Add query to batch httpquery
        batch.add(link)

        #keep track of what's been added to the batch
        print('adding ' + updatesite +
                ' to batch request for ' + propertyname)

    #verify the batch object and execute
    print(batch)

    batch.execute(http=None)

期望:在尽可能少的查询中更新分析配置文件

结果:

请求6返回API错误:403:配额错误:超过写入速率限制。你知道吗

那么

请求12返回API错误:403:配额错误:超出用户速率限制。你知道吗

那么

请求1返回API错误:403配额错误:配额错误:您已超过此项目每天的最大写入次数。你知道吗


Tags: to方法https视图apihttpfor数量
1条回答
网友
1楼 · 发布于 2024-09-28 21:41:46

因此,在与脚本进行了大量斗争之后,批处理并不是每天向分析中插入超过50个调用数据的选项。你知道吗

我不得不使用puppeter在分析中自动批量重命名视图名称。你知道吗

相关问题 更多 >