bashvisual-studio-codecurl

How to download vs code with curl?


Seems like a simple question but

curl -L -o code.tar.gz https://code.visualstudio.com/docs/?dv=linux64cli&build=insiders

Gives me an HTML file. I tried many other combinations and even wget but couldn't make it work

Tried curl with many options, wget as well. Other answers here all mention the -L but in this case it does not work


Solution

  • use the "direct link" (even that link is not really the "direct link" but a redirect to the direct link, thus you still need -L ) enter image description here

    curl -L -o code.tar.gz 'https://code.visualstudio.com/sha/download?build=insider&os=cli-alpine-x64'
    

    btw if you want to do a fancy/complex request, curl is the better option, but if you just want to download something, wget is the better option. For example, if your internet connection drops half-way, curl will just abort the download and return an error code. wget will try to resume the download from where it cut off, first by using a Range request, and if it detects that the server does not support range-requests, it will restart the download from the beginning, up to 20 times (configurable), before giving up.