curl is a powerful command - line utility to pass with a web host via the depot . Often , it gets obscure with the popular wget command as both of them can upload and download contents to a server and they do turn interbreeding - program . So , to clear things up , here are the conflict between wget and curl and some popular scroll commands that you should bonk to depart off .
curl vs wget
On the airfoil , both Robert Floyd Curl Jr. and wget can be seen as a public-service corporation that can request and download content from the web servers . However , if you dig down late , there is a lot to unravel . curl supports many more protocols ranging from HTTPS , SFTP to IMAP , POP3 , etc whereas , wget only keep going HTTP , HTTPS , and FTP .
Another major conflict is that wget supports recursive download whereas curl does n’t . So , wget will download everything from the web page to pages it is yoke with whereas curl wo n’t . On the other mitt , curl is based on the libcurl library which provides genus Apis . Hence , it can be easily used in command - line of products scripting as well as GUI base apps . you could think of curl as a stripped - down command - line web web browser which can upload and download contents from a WWW server .
Installing curl onWindows
curl comes pre - set up on Unix - based or Unix - like Operating system and hence it can be directly used on macOS . However , it can also be used on non - Unix systems like Windows with the assistance of a “ libcurl ” library .
In Windows , all we have to do is download the libcurl zip single file and make a duet of change to make it usable via the command prompt . Firstly , download thelibcurl naught filefor your Windows 32 - bit or 64 - bite accordingly . After you have downloaded the file , express the substance in a leaflet . For context , the comply is a screenshot of the extracted content of the libcurl pamphlet .
Within the extracted folder , head over to thebinfolder and copy the following Indian file – “ curl.exe ” and “ curl - ca - bundle ” .
Create a brochure call “ curl ” within the “ deoxycytidine monophosphate : ” drive and glue both the copied files . Once you have done this , you may directly use the curl command when you navigate to the “ C:\curl ” folder within the command prompting .
Alternatively , if you would care to run curl now from the cmd , I would urge creating an environment varying . To do that , head over to the Start computer menu and type “ cut the system environment variables ” and sink in on the first search .
On the System Properties crop up - up windowpane , select the Environment variables release at the bottom .
On the environs varying screen , snap on the fresh button on the upper half to add a user environs varying .
In the new User Variable projection screen , add the follow entrance . Post that , snap on Ok and next Apply to save the changes .
Once done , clack on Ok under the Environment variable menu to keep start the change . Post this , you should be able to use the curl bidding directly on the command command prompt . To test it , inscribe the following command
Alternatively , you may alsoenable WSL for Windowsand use theUbuntu bash shellto feed curl instruction from bash on Windows .
Best Curl Commands and How to Use It
Before we commence with the commands , do note that individual quotes do n’t work in the Windows command line . You would have to commute them to two-fold - quotes . For the belt shell , it would work as usual with the single inverted comma as well .
1 . Browse HTML code
The most basic utility of curl is to browse the HTML code of a webpage . To do that , suffix the curl dictation with the web uniform resource locator of the webpage .
This command will display the output on the terminal . you could also download the message of the Indian file by specifying the “ -O ” switch prior to the URL . This will economize the file cabinet on your system of rules with the same remote file name . For example , if the hypertext mark-up language file name on the waiter is “ home.html ” , it will be lay aside topically as “ home.html ” as well .
instead , you may store the datum with custom file cabinet names . For that , append the command with a little case “ -o ” followed by the filing cabinet name .
you may also download multiple files by specifying multiple remote Indian file URLs .
2 . Downloading files with curl
alike to wget , you may download files using curl . you could use the -o switch and specify the file name or else the file will be carry through with the distant file name .
For good example , the following command will download the belated variation of Linux mint from the webserver .
you’re able to also use “ - # ” or “ – onward motion - bar ” to display the onward motion in the form of hashish .
3 . Resuming Failed Download
Moreover , if the download is disrupt , you’re able to resume by using the “ -C - ” switch . The command will look like as follow .
For example , the espouse command will resume the download from the last failed degree .
4 . IP Information
you could utilize the following curl mastery to get all the internet entropy about a political machine
Alternatively , if you bonk the IP reference and you want other details like the location atomic number 27 - ordinates , city , timezone , etc , you’re able to use the watch variation of the control .
5 . Send electronic mail
Since curl supports SMTP , POP3 protocol , you’re able to even apply it to post electronic mail . Below is a sample of sending an email via Gmail .
supervene upon the electronic mail reference and password in the following program line consequently .
Make certain youturn on access for less inviolable appsfor the Google account
6 . Dictionary
The dict communications protocol provided by the libcurl can be used to easily find the import of a Holy Writ . The source of the meaning isWordNet . Below is the mastery to do the same .
7 . POST command
you may place POST requests to a web host with the helper of a curl command . The syntax is as follows
The POST form information can also be transport in the pattern of a JSON data file . employ the take after mastery to do that .
8 . Convert Files
Since curl substantiate multipart form data , you may use it to upload file cabinet and even get them converted instantly . For case , I want to get this hypertext markup language file exchange to a PDF . Hence , I will be using theDocverter APIto do this . The Docverter API affirm multiple single file - data format from HTML , Markdown and can commute them to Docx , PDF , ePub , etc .
Alternatively , you may also use theGoogle Drive API v3to convert excel spreadsheet , documents , etc .
Closing Words
Also Read:14 Best pick up to Code Apps ( Android & iOS )