I am trying to automatically download earnings report from Google Play through Google Cloud Storage and their client api library for python, googleapiclient
.
I use python 3.6.5 (Anaconda distribution) on Windows 10:
client_email = '...@...iam.gserviceaccount.com'
json_file_path = 'C:\\Users\\...'
cloud_storage_bucket = 'pubsite_prod_rev_...'
report_to_download = 'sales/salesreport_201806.zip'
json_obj = json.loads(open(json_file).read())
_private_key = json_obj['private_key']
_private_key_id = json_obj['private_key_id']
_token_uri = json_obj['token_uri']
_client_id = json_obj['client_id']
credentials = ServiceAccountCredentials(
service_account_email = client_email,
private_key_id = _private_key_id,
token_uri = _token_uri,
client_id = _client_id,
scopes = 'https://www.googleapis.com/auth/devstorage.read_only',
signer = crypt.Signer.from_string(_private_key), )
storage = build('storage', 'v1', http=credentials.authorize(Http()))
request = storage.objects().get_media(bucket=cloud_storage_bucket,
object=report_to_download)
response = request.execute()
However, I get some protocol buffer file as response
, which starts like this: b'PK\\x03\\x04\\x14\\x00\\x08\\x08\\x08\\x00\\xdb\\xa3\\xe4L\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x13\\x00\\x00\\x00PlayApps_201806.csv'
I cannot figure out which decoder I should use to get response
in a better format (when downloaded manually from Google Play, the report is .csv
file in a .zip
archive). Any suggestions?
This isn't a protobuf. It is a zip file. The clues
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.