代理

如果您需要通过代理连接到 Google Ads API,可以通过在 google-ads.yaml 文件中设置 http_proxy 配置来实现此目的:

# Proxy configuration
###############################################################################
# Below you can specify an optional proxy configuration to be used by         #
# requests. If you don't have username and password, just specify host and    #
# port.                                                                       #
# #############################################################################
http_proxy: INSERT_PROXY_HERE

例如,您可以指定 http://user:pass@localhost:8082 作为代理。或者,您也可以使用 GoogleAdsClient 方法(load_from_dictload_from_envload_from_string)以编程方式配置代理设置,就像其他任何配置设置一样。例如:

config = {
  ...
  "http_proxy": "INSERT_PROXY_HERE",
}
googleads_client = GoogleAdsClient.load_from_dict(config)

如需将代理与 load_from_env 方法搭配使用,请设置 GOOGLE_ADS_HTTP_PROXY 环境变量。