如果您需要通过代理连接到 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_dict
、load_from_env
和 load_from_string
)以编程方式配置代理设置。例如:
config = {
...
"http_proxy": "INSERT_PROXY_HERE",
}
googleads_client = GoogleAdsClient.load_from_dict(config)
如需将代理与 load_from_env
方法搭配使用,请设置 GOOGLE_ADS_HTTP_PROXY
环境变量。