0

I am trying to download only one .tar file (Task03_Liver.tar) from this Google Drive link: https://drive.google.com/drive/folders/1HqEgzS8BV2c7xYNrZdEAnrHk7osJJ--2 into Google Colab with Python on Windows.

However, I do not know how to do it properly because I am getting a HTML file instead of the .tar file.

I tried the !wget command but it is not working. It does not show any error but I guess I am adding a wrong link or maybe there's another command to extract a specific file from a Google Drive folder.

!wget https://drive.google.com/file/d/1jyVGUGyxKBXV6_9ivuZapQS8eUJXCIpu/view

And I get the following:

--2022-11-26 10:36:54--  https://drive.google.com/file/d/1jyVGUGyxKBXV6_9ivuZapQS8eUJXCIpu/view
Resolving drive.google.com (drive.google.com)... 74.125.142.113, 74.125.142.100, 74.125.142.138, ...
Connecting to drive.google.com (drive.google.com)|74.125.142.113|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘view’

view                    [ <=>                ]  72.73K  --.-KB/s    in 0.004s  

2022-11-26 10:36:55 (17.7 MB/s) - ‘view’ saved [74476]

It is an HTML file but I expect a .tar file downloaded

George
  • 29
  • 4
  • `https://drive.google.com/uc?export=download&id=FILEID` where FILEID is `1jyVGUGyxKBXV6_9ivuZapQS8eUJXCIpu` in your case – Edo Akse Nov 26 '22 at 11:18
  • but you should actually use the API for this though. See [this question](https://stackoverflow.com/questions/38511444/python-download-files-from-google-drive-using-url) for examples – Edo Akse Nov 26 '22 at 11:20
  • I tried `!wget https://drive.google.com/uc?export=download&id=1jyVGUGyxKBXV6_9ivuZapQS8eUJXCIpu`, but it is not working – George Nov 26 '22 at 11:32
  • I get this: `--2022-11-26 11:33:03-- https://drive.google.com/uc?export=download Resolving drive.google.com (drive.google.com)... 74.125.142.138, 74.125.142.139, 74.125.142.102, ... Connecting to drive.google.com (drive.google.com)|74.125.142.138|:443... connected. HTTP request sent, awaiting response... 400 Bad Request 2022-11-26 11:33:03 ERROR 400: Bad Request.` – George Nov 26 '22 at 11:34
  • weirdly enough it no longer seems to work in wget nor curl. If you paste that link into a webbrowser it does download it directly though. Is downloading the file inside your code an option? – Edo Akse Nov 27 '22 at 13:39
  • Yes, it is an option. Or what do you mean by this? I can download with other links – George Dec 01 '22 at 11:00
  • well if downloading from within python code is an option, take a look at [this question](https://stackoverflow.com/q/38511444/9267296) – Edo Akse Dec 01 '22 at 13:16

0 Answers0