Why does the same curl -o file https://www.link.com/
command output different things?
For example if i run the command curl -o source.txt https://www.youtube.com/playlist?list=PLIx6FwnpuyNW9RxmWaGzKumLu-gUPy-q4
with a YouTube playlist link.
Linux output everything including all of the entries (titles, thumbnails, links, etc.).
Windows on the other hand will only output the layout of the page, skipping everything playlist stuff.
What am I missing here? Why is this the case and is there a different Windows command that achieves the same thing?
CodePudding user response:
Curl.exe
is present in box on Windows machines with Windows 10 1803 or higher (which means since roughly March of 2018) and similar server releases.
However, curl
(with no .exe) has a somewhat weird history and some shortcuts are left behind built into PowerShell, and I think that is what's causing you some grief.
What do I mean?
Give this a try on your machine.
get-command curl
CommandType Name Version Source
----------- ---- ------- ------
Alias curl -> Invoke-WebRequest
You might be surprised to find that curl
in PowerShell is an alias for a built-in cmdlet called Invoke-WebRequest
. This acts somewhat similarly to curl
in Linux or the curl.exe
program, but is really quite different.
However, try that again with the full executable name.
gcm curl.exe
CommandType Name Version Source
----------- ---- ------- ------
Application curl.exe 7.55.1.0 C:\WINDOWS\system32\curl.exe
This means that running curl
and running curl.exe
are two different things!
If you try your command like so, it should be similar to what you find in Linux.
curl.exe -o source.txt https://www.youtube.com/playlist?list=PLIx6FwnpuyNW9RxmWaGzKumLu-gUPy-q4