I want to implement a program with auto-update, and for this I need the script to download the file from Google Drive. Immediately I say that the file is in the open for reading and downloading access. But how to do this if you can’t get a link to the file itself, so I don’t know how to implement it.
2 answers
import urllib.request logo = urllib.request.urlopen("https://drive.google.com/........download").read() f = open("имя файла с расширением", "wb") f.write(logo) f.close() I can give a clear example:
import urllib.request logo = urllib.request.urlopen("https://drive.google.com/uc?id=1gkTOtZ7K72IxxTQ8W1bHMmLglvAYUfIe&export=download").read() f = open("photo.jpg", "wb") f.write(logo) f.close() But to get such a link, ending in download, you must first follow the link specified for public access, and then click on the download icon. And the link that opens will, in fact, end in download, and this is exactly what we needed. And then just copy it into the insert.
- Can you add an option for Python 2? - Mihail Ris
- Unfortunately no. I do not understand much in 3 python, and I don’t know the second one all the more. So I’ll be able to help her here - Mikhail Muratov
|
The Google Drive service has its own RESTful API . Through it you can get data about the file and download it.
|
WebDriver? If I understand the essence of the problem. - approximatenumber