Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python中将Google广告报告导出为csv?(获取AuthenticationError和HTTP错误400)_Python_Python 3.x_Google Ads Api - Fatal编程技术网

如何在Python中将Google广告报告导出为csv?(获取AuthenticationError和HTTP错误400)

如何在Python中将Google广告报告导出为csv?(获取AuthenticationError和HTTP错误400),python,python-3.x,google-ads-api,Python,Python 3.x,Google Ads Api,连接到ADSAPI,使用凭据配置yaml,测试google的python示例代码,但收到上述错误。如何将所有时间的简单关键字性能报告导出到csv 使用Jupyter在Python 3.6上测试和运行代码。我使用了以下代码: 或者,使用以下选项,但得到相同的错误: # Using Pandas from googleads import adwords import pandas as pd import numpy as np import io # Define output as a s

连接到ADSAPI,使用凭据配置yaml,测试google的python示例代码,但收到上述错误。如何将所有时间的简单关键字性能报告导出到csv

使用Jupyter在Python 3.6上测试和运行代码。我使用了以下代码:

或者,使用以下选项,但得到相同的错误:

# Using Pandas

from googleads import adwords
import pandas as pd
import numpy as np
import io

# Define output as a string
output = io.StringIO()

# Initialize appropriate service.
adwords_client = adwords.AdWordsClient.LoadFromStorage()

report_downloader = adwords_client.GetReportDownloader(version='v201809')

# Create report query.
report_query = ('''
select Date, HourOfDay, Clicks
from ACCOUNT_PERFORMANCE_REPORT
during LAST_7_DAYS''')

# Write query result to output file
report_downloader.DownloadReportWithAwql(
    report_query, 
    'CSV',
    output,
    client_customer_id='xxx-xxx-xxxx', # denotes which adw account to pull from
    skip_report_header=True, 
    skip_column_header=False,
    skip_report_summary=True, 
    include_zero_impressions=False)


output.seek(0)

df = pd.read_csv(output)

df.head()

期望通过指定的google ads报告获得某种输出。

客户_customer_id='xxx-xxx-xxxx'查看的是主帐户,而不是客户帐户,更新后的帐户现在可以正常工作。

以下内容为我提供了除子帐户以外的所需内容-如果将其用于家长/经理帐户,那将是非常好的:
# Using Pandas

from googleads import adwords
import pandas as pd
import numpy as np
import io

# Define output as a string
output = io.StringIO()

# Initialize appropriate service.
adwords_client = adwords.AdWordsClient.LoadFromStorage()

report_downloader = adwords_client.GetReportDownloader(version='v201809')

# Create report query.
report_query = ('''
select Date, HourOfDay, Clicks
from ACCOUNT_PERFORMANCE_REPORT
during LAST_7_DAYS''')

# Write query result to output file
report_downloader.DownloadReportWithAwql(
    report_query, 
    'CSV',
    output,
    client_customer_id='xxx-xxx-xxxx', # denotes which adw account to pull from
    skip_report_header=True, 
    skip_column_header=False,
    skip_report_summary=True, 
    include_zero_impressions=False)


output.seek(0)

df = pd.read_csv(output)

df.head()