how to use wget with Julia

Viewed 774
3 Answers

The equivalent of Python's wget in Julia is download

To get the file to your disk just run:

download("https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data","./autofile.txt")

Do not use run for this because you take a risk that your code will not be portable.

In order to download files, I tend to use the following helper function, which is fully implemented in Julia, does not rely on the availability of external tools, and is therefore entirely portable across systems (it does, however, depend on HTTP.jl):

import HTTP

function http_download(url, dest)
    HTTP.open(:GET, url) do http
        open(dest, "w") do file
            write(file, http)
        end
    end
end

http_download("http://www.julialang.org/", "/tmp/index.html")
Related