我已经安装了 Anaconda 并且在尝试通过 Jupyter Notebooks 进行 API 调用时遇到了 SSL 问题:
import requests
import certifi
r = requests.get('https://github.com/')
print(r)
Run Code Online (Sandbox Code Playgroud)
这首先产生了 SSL 连接错误。经过广泛的搜索和我们 IT 部门的帮助,我可以解决这个问题。这里的解决方案是将公司根证书添加到 certifi 证书存储中。
现在对于其他请求,不幸的是我仍然遇到同样的问题。使用 google2pandas 包调用 Google Analytics API 的示例代码:
from google2pandas import *
query = {
'reportRequests': [{
'viewId' : 37616054,
'dateRanges': [{
'startDate' : '8daysAgo',
'endDate' : 'today'}],
'dimensions' : [
{'name' : 'ga:date'},
{'name' : 'ga:pagePath'},
{'name' : 'ga:browser'}],
'metrics' : [
{'expression' : 'ga:pageviews'}],
'dimensionFilterClauses' : [{
'operator' : 'AND',
'filters' : [
{'dimensionName' …Run Code Online (Sandbox Code Playgroud) 我正在使用 Google Cloud Function 来运行 ETL 作业:
云调度程序 cron 作业每晚运行以触发云功能。我还可以手动运行管道来查询特定日期。云函数是用Python编写的。
这项工作的运行时间总是接近 9 分钟,但几个月来效果还不错。不幸的是,现在我已经达到了 Google Cloud Functions 的 9 分钟硬限制,我想知道我的最佳选择是什么:
还有更好的选择吗?哪种 GCP 服务非常适合此任务?您有任何最佳实践吗?我真的很喜欢云功能的简单性,但这当然需要权衡......
google-app-engine google-compute-engine google-cloud-platform google-cloud-functions