如果您需要透過 Proxy 連線至 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
指定為 Proxy。或者,您也可以使用 GoogleAdsClient
方法 (load_from_dict
、load_from_env
和 load_from_string
),以程式輔助方式設定 Proxy,就像其他設定一樣。例如:
config = {
...
"http_proxy": "INSERT_PROXY_HERE",
}
googleads_client = GoogleAdsClient.load_from_dict(config)
如要使用 load_from_env
方法搭配 Proxy,請設定 GOOGLE_ADS_HTTP_PROXY
環境變數。