Curl is a command-line tool used for transferring data using various protocols, including HTTP, HTTPS, FTP, and more. It is quite handy when you want to download a webpage.
In order to use Curl to download a webpage, you can use the following command:
curl http://example.com > example.html
In the above command:
curl
is the command line tool you are using.http://example.com
is the URL of the webpage that you want to download.- The
>
character is a redirection operator which is used to redirect the output from the curl command (the contents of the webpage) into a file. example.html
is the file where the output will be saved.
This command will create a new file named example.html in your current directory, and it will contain the HTML source code of the webpage.
Remember to replace http://example.com
with the URL of the webpage you want to download. Also, be aware that the above command will overwrite the example.html
file if it already exists. If you want to append the output to the file instead of overwriting it, you can use >>
instead of >
:
curl http://example.com >> example.html
This command will append the output to the example.html
file. If the file does not exist, it will be created.
You can also use the -o
or --output
option followed by the filename to write output to instead of stdout:
curl -o example.html http://example.com
With this command, Curl will write the output to the example.html
file. If the file already exists, it will be overwritten. If it does not exist, it will be created.
You can also use the -O
or --remote-name
option if you want Curl to write output to a file with the same name as the remote file:
curl -O http://example.com/example.html
With this command, Curl will write the output to a file named example.html
.
If the webpage is on a secure server (the URL starts with https://
), you can use the -k
or --insecure
option to tell Curl to proceed with the operation without checking the SSL certificate:
curl -k https://secure.example.com > secure_example.html
With this command, Curl will download the webpage from https://secure.example.com
and save it to the secure_example.html
file.