Uploading Public Files to Google Drive (Python)

Let's say someone gives me a link that allows me to upload a publicly available file to Google Drive.

I want to write a program that can read a link and then download it as a text file.

For example, https://docs.google.com/document/d/1yJVXtabsP7KrJXSu3XyOh-F2cFoP8Lftr14PtXCLEVU/edit is one of the files in my Google Drive. Anyone can access this file.

But how can I write a Python program that downloads the text file given by the above link?

Can anyone have some sample code for me?

It seems that some Google Drive SDKs might be helpful (?), But is there a way to do this without using the SDK?

+3


source to share


1 answer


first, you need to write a program that will cut the link to the file you downloaded. for example in the link you gave:   https://docs.google.com/document/d/1yJVXtabsP7KrJXSu3XyOh-F2cFoP8Lftr14PtXCLEVU/edit

id 1yJVXtabsP7KrJXSu3XyOh-F2cFoP8Lftr14PtXCLEVU



store it in some variable say download_link now to get the download link: https://docs.google.com/uc?export=download&id=download_link this link will download the file

+2


source







All Articles