How to use wget to download files from Onedrive? (and batch files and entire folders, if possible)
-
1Please take a look at superuser.com/questions/833199/… "In Office 365 how do I get a direct download link for an Excel document stored in One Drive for Business?" to see if that answers your question. – steve Aug 17 '15 at 16:08
-
But is necessary subscripted account in Office365. – charles Aug 17 '15 at 16:48
-
1Use the OneDrive client that someone has kindly written for Linux ? github.com/xybu/onedrive-d-old – steve Aug 17 '15 at 16:53
-
Try to download the file to your browser, while the download is running, right click and 'copy download link'. If you are lucky you can wget that link. – Baazigar Aug 17 '15 at 18:33
-
I try Onedrive-d, but couldn't do 'get' work. Really by copying link to file and put in 'wget', it works, thank you. – charles Aug 17 '15 at 20:12
There is one way that works for me (based on How to Make Direct Link of OneDrive Files)
Right-click on the file you are interested in download (from web interface), and choose Embed.
Press "Generate HTML code to embed this file".
Copy the part contained in the
""
of src is your link. This will look like .Replace
embed
withdownload
. This will look like https://onedrive.live.com/download?cid=6EBB03E38A53ED3E&resid=6EBB03E38A53ED3E%21116&authkey=AC4lDqtLG8LqfiA.Feed it to
wget
using following syntax (the quotes are required):wget --no-check-certificate "https://onedrive.live.com/download?cid=6EBB03E38A53ED3E&resid=6EBB03E38A53ED3E%21116&authkey=AC4lDqtLG8LqfiA"
Enjoy.
-
-
1One must not forget to put the link in
""
inwget
. I did and it didn't work. – Dushyant Bangal Mar 8 '17 at 9:58 -
-
Using Chrome (but Firefox will probably also work).
- Open DevTools
- Click the Download button.
- Download but cancel immediately
- Open the 'Network' tab in DevTools. Search for 'Zip?authKey=' in DevTools and open it (click). This is a POST request.
- Click 'View source' to the right of 'Form data' at the bottom.
- Construct the command as follows:
wget --post-data='<raw form data>' '<Download URL>'
Or:
wget --post-data='resIds=xxx&canary=yyy&authkey=zzz' 'https://cid--foobar.users.storage.live.com/downloadfiles/V1/Zip?authKey=zzz'
This even works on a different host (with a different IP address).
-
3A simpler variation on this (using Firefox) is: Tools->Web Developer->Network. Find 'Zip?authKey=', right click on it and 'Copy as cURL'. Copy-paste into the command line and add '-o /path/to/some/file'. Of course this uses cURL instead of wget, but for this purpose they function identically – happyskeptic Dec 25 '17 at 4:41
-
generate a sharing link and append "&download=1" to the end of it.
e.g. if the link is "https://some.host/:z:/x/personal/some_user/123456asdf?e=12345"
then
wget "https://some.host/:z:/x/personal/some_user/123456asdf?e=12345&download=1"
-
1
-
If you are looking to download an entire publicly shared folder (without auth!): OneDeath
It uses wget to do some API calls and will then recursively download files. Bonus: sha1 checks of finished files.
Sharepoint is now also supported, but it's a little trickier (it currently fetches more files from a drive than what is shown by the link). A major problem was a slightly different API structure and the fact that the session token expires after 1h, but it's solved too. They also appear to have some rate-limiting in place, so don't start too many parallel downloads.
The script can extract ready-to-use wget
commands using the -w
parameter.
PS: If you are interested to know more about the web API, I will give a run down of the process.
This python SDK (with example) for OneDrive project works (for personal, business, and corporate accounts):
- Open the link in web interface like Chrome.
- Click "Download" on the top left.
- At the bottom, click "Show All".
- Find the downloading or downloaded file, right click the long link and click "Copy Link Address".
- wget the long address in command line.
-
probably the only one working way to download some shared files if you don't want to install additional tools or bring the python code to extract objects – cyberbolt Dec 10 '20 at 13:26