Every website requires headers in different formats. You can initiate a request from a browser and see the headers. And generate an equivalent curl command and use it in Google Colab. Many browsers directly give you the option to Copy as curl (Bash) which you can directly use in Google Colab. Here’s a simple way to do it with Google Chrome: First, have a Google Colab notebook ready and connected to a runtime. Also, make sure you have mounted your Google Drive. Go to the mediafire page you want to download from. Hover over the download button. You can see the link it leads to in the bottom-left of your browser. If it is of the form downloadxxxx.mediafire.com/... right-click and copy the link address. Otherwise, it’s an AD. Inspect the page source (CTRL+U) to get the link. Press CTRL+F and look for “Download file”. You will see the download link of the form downloadxxxx.mediafire.com/... . Copy that link. Now, open a new tab. Open Developer Tools. (CTRL+SHIFT+I on Chrome). Head over to the Network tab. Paste the download link in the address bar and hit ENTER. Cancel the download. You will be able to find the request made by the browser:
Right click → Copy → Copy as cURL (bash). Now, head over to the Colab Notebook, and paste the command. Add a “!” (exclamation mark) at the beginning of the command, so it is recognized as a bash command. Also, you need to add the output file name at the end using the --output” parameter. Your final command should look like this: !curl '
' \ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp ,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Connection: keep-alive' \ -H 'Cookie: ...' \ -H 'Sec-Fetch-Dest: document' \ -H 'Sec-Fetch-Mode: navigate' \ -H 'Sec-Fetch-Site: none' \ -H 'Sec-Fetch-User: ?1' \ -H 'Upgrade-Insecure-Requests: 1' \ -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \ -H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'sec-ch-ua-platform: "Windows"' \ --compressed --output The file will be downloaded to the disk associated with the notebook, in the “content” folder. You can download the file from here, or copy it to your drive using the “cp” command:
!cp "/content/drive/MyDrive/" Assuming that you have mounted Google Drive in the path “/content/drive”.