使用api下载Google文档

问题描述 投票:0回答:1

这是可共享的链接link to file

ID = 1wzCjl51u131v1KBgpbiKLJs8DPPakhXCFosfYjp7BY0

所以manage downloads文件。

file_id = '11wzCjl51u131v1KBgpbiKLJs8DPPakhXCFosfYjp7BY0'
request = drive_service.files().export_media(fileId=file_id,
                                             mimeType='application/pdf')
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
    status, done = downloader.next_chunk()
    print ("Download %d%%." % int(status.progress() * 100))

我将文件保存为dd.py,使用f5运行并出现此错误

第2行,在request = drive_service.files()。export_media(fileId = file_id,NameError:name'drive_service'未定义

python google-drive-api google-api-python-client
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.