linux - how to download dropbox files using wget command?

18
2014-04
  • hugemeow

    Seems I can only download dropbox files using explorer such as chrome and firefox. If I use wget to download, then I would get a file which is in html format. Why?

    For example you can open this link

    You would not get the content of this file, why? The following is part of test.txt to download it, this is not the content of test.txt at all.

    So is it possible to download Dropbox files using wget rather than explorer?

    document.observe('script:loaded', function() {
    SharingModel.init('test\x2etxt', Util.from_json('\x7b\x22item\x5fid\x22\x3a\x20\x22\x22\x2c\x20\x22secure\x5fhash\x22\x3a\x20\x22\x22\x2c\x20\x22subpath\x22\x3a\x20\x22\x22\x2c\x20\x22tkey\x22\x3a\x20\x22mx9eqve5l2ipgyk\x22\x7d'))
    SharingModel.init_file()
    $('emsnippet-9911dfc627e1d541').innerHTML = 'test\x2etxt'.em_snippet(50, 0.750).escapeHTML();
    $('emsnippet-add7879f5d805012').innerHTML = 'test\x2etxt'.em_snippet(20, 0.750).escapeHTML();
    $('emsnippet-981ac0639529f983').innerHTML = 'test\x2etxt'.em_snippet(20, 0.750).escapeHTML();
    FilePreview.init_text('https\x3a\x2f\x2fdl\x2edropbox\x2ecom\x2fs\x2fmx9eqve5l2ipgyk\x2ftest\x2etxt', 0)                        });
                        } else if (window.jQuery) {
    jQuery(function () {
    SharingModel.init('test\x2etxt', Util.from_json('\x7b\x22item\x5fid\x22\x3a\x20\x22\x22\x2c\x20\x22secure\x5fhash\x22\x3a\x20\x22\x22\x2c\x20\x22subpath\x22\x3a\x20\x22\x22\x2c\x20\x22tkey\x22\x3a\x20\x22mx9eqve5l2ipgyk\x22\x7d'))
    SharingModel.init_file()
    $('emsnippet-9911dfc627e1d541').innerHTML = 'test\x2etxt'.em_snippet(50, 0.750).escapeHTML();
    $('emsnippet-add7879f5d805012').innerHTML = 'test\x2etxt'.em_snippet(20, 0.750).escapeHTML();
    $('emsnippet-981ac0639529f983').innerHTML = 'test\x2etxt'.em_snippet(20, 0.750).escapeHTML();
    FilePreview.init_text('https\x3a\x2f\x2fdl\x2edropbox\x2ecom\x2fs\x2fmx9eqve5l2ipgyk\x2ftest\x2etxt', 0)                        });
                        } 
    

    I cannot get test.txt with command

    wget https://www.dropbox.com/s/mx9eqve5l2ipgyk/test.tx
    
    
    ls -l 
    -rw-rw-r-- 1 mirror mirror  30K Sep  6 15:01 test.txt
    
  • Answers
  • amotzg

    The link in your question is not the link to the file, is a link to the Dropbox page of this file.
    If you want to use wget to download it, you should copy the link to direct download from the menu that drops when pushing the download button to the right.

    In my case, that worked fine. However, sometimes problems in downloading links from outside the browser relate to parameters other than the link itself. A common element that does not exist when you simply copy the link are the site cookies.

    Try this cool FF add-on to get the correct wget links

    And also, especially if we are talking about a known workstation and not a casual one, you can of course install the Dropbox client. This will be the easiest way, just let your box be part of your file structure and eliminate the need of complicated downloads.
    See this askubuntu.com post, and the Dropbox download page.

  • slhck

    Just add ?dl=1 at the end of the link! For example: https://www.dropbox.com/s/mx9eqve5l2ipgyk/test.txt?dl=1

    That should give you a fine retrieval of the file in question without adding anything to the file.

    One more thing! If you wanna save the file somewhere else use the -O option like this

    wget -O /root/Desktop/test.txt "https://www.dropbox.com/s/mx9eqve5l2ipgyk/test.txt?dl=1"
    

    And if you want to have a little bit of GUI you can use zenity to mark the location to where the file is going to be downloaded!

    Here's an example code:

    #!/bin/bash
    dir=$(zenity --file-selection --directory)
    wget -O $dir/test.txt "https://www.dropbox.com/s/mx9eqve5l2ipgyk/test.txt?dl=1"
    
  • Community

    Dropbox has modified it so that wget will do the right thing and retrieve the file instead of the interstitial.

    Use "Share Link" to retrieve the direct link to the file.


  • Related Question

    WGET command line for download videos
  • Steve Cooper

    I'm trying to figure out WGET for downloading some videos at http://windowsclient.net/learn/videos_wpf.aspx.

    This page is an index page, and contains links to a page for each video; each page then has a direct link to a video. Something like;

    http://windowsclient.net/learn/videos_wpf.aspx
      -> http://windowsclient.net/learn/video.aspx?v=300881
        -> http://download.microsoft.com/[...]/HDI-WPF-ipod-AccelerometerJoystick(2).mp4
    

    What I'd like to do is tell WGET to spider the site by following either video.aspx?* or .mp4 links, recurively, for two levels. I can figure out

    WGET -r -l2 http://windowsclient.net/learn/videos_wpf.aspx
    

    and then I get stuck. Any suggestions greatly appreciated.

    EDIT: Thanks to @mloskot, I got the answer;

    WGET -r -l2 -A.mp4,video*.aspx* 
      --domains=windowsclient.net,download.microsoft.com 
      --span-hosts 
      http://windowsclient.net/learn/videos_wpf.aspx
    

  • Related Answers
  • mloskot

    Learn about option -A in the 2.11 and 4.2 chapter of wget manual and use this option to specify comma-separated lists of file name suffixes or patterns to accept. In other words, use -A to specify that you want to download only files with mp4 extension:

    WGET -r -l2 -A.mp4 http://windowsclient.net/learn/videos_wpf.aspx