5 ms·
alias wget="curl -sL -O --no-clobber" Update: Based on comments from @xorcist and @stabbles: alias wget="curl -fLsS --no-clobber --remote-name-all"
by msravi 4y ago
alias wget="curl -sL -O --no-clobber"
Update: Based on comments from @xorcist and @stabbles:
alias wget="curl -fLsS --no-clobber --remote-name-all"
- amelius 4y agoOr just use wget ;)
- msravi 4y agoThe best thing about curl is that developer tools of browsers (firefox for example) have a convenient "Copy as curl" feature that mimics the web request. The reason there isn't a "Copy as wget" option, I think, is the level of control that curl allows so the request can be tailored to exactly mimic the browser. But when you want to recursively download a website, of course, nothing better than wget. curl doesn't support that, and you'll need to parse and fetch the urls recursively yourself with a script.
- amelius 4y agoCopying from the web and pasting in a terminal, is that not a bad practice from a security viewpoint?
- Lukas_Skywalker 4y agoThe command comes from a text field of the developer tools, which are provided by the browser vendor, not the websites. It allows you to repeat a request that the browser did, but in your own terminal. It only downloads data, but doesn‘t run downloaded scripts.
- amelius 4y agoOk, I misread that.
- verhovsky 4y agoYou can paste that curl command into https://curlconverter.com/wget/ https://curlconverter.com/wget/ to turn it into a Wget command. > The reason there isn't a "Copy as wget" option, I think, is the level of control that curl allows so the request can be tailored to exactly mimic the browser. That's not true. You can read the code that generates the curl command, it's pretty straightforward: https://github.com/ChromeDevTools/devtools-frontend/blob/c9afdb4745a76866f7486be0e5cdd4e2b270d8af/front_end/panels/network/NetworkLogView.ts#L2033 https://github.com/ChromeDevTools/devtools-frontend/blob/c9a... The arguments it uses are --url, --data-raw, -X/--request, -H/--header, --compressed and --insecure, all of which Wget has an analog of. I think the reason is that they don't care to do it and/or they don't want to make that "Copy" dropdown too long.
- stabbles 4y agoNot the same... you need: `-S` to print error messages and `-f` to return exit code on non-200 responses. Also, --no-clobber is very recent (v7.83), so unlikely to work in general. So `curl -fLOsS ...`
- xorcist 4y agoThat will only download the first argument. You need --remote-name-all instead of -O (--remote-name) to download all arguments files. It was in my opinion a mistake in the curl cli that remote-name works like output and needs to be repeated for each url. Remote-name-all is what rename-name should have been all along.
- JetSpiegel 4y agoThe curse of a non-breaking API...
- deleted 4y ago[deleted]