CURL: Difference between revisions
mNo edit summary |
|||
Line 1: | Line 1: | ||
{{TOCright}} | {{TOCright}} | ||
<code> | <code>cURL</code> is a computer software project providing a library and command-line tool for transferring data using various protocols. The <code>cURL</code> project produces two products, '''libcurl''' and '''cURL'''. It was first released in 1997. The name originally stood for {{FormFCTW|8|blue|bold|see URL}} <ref name="wikipedia>[[wikipedia::cURL|cURL]] wikipedia</ref>. | ||
The website of <code>cURL</code> opens with: ''A command line tool and library for transferring data with URLs'' <ref name="curl">[https://curl.haxx.se curl.haxx.se]] Home page of cURL and libcurl.</ref>. | |||
== What's <code>cURL</code> used for == | |||
cURL is used in command lines or scripts to transfer data. | |||
It is also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets, settop boxes, media players and is the internet transfer backbone for thousands of software applications affecting billions of humans daily. | |||
== Who makes <code>cURL</code> ? == | |||
<code>cURL</code> is free and open source software and exists thanks to thousands of contributors. | |||
The <code>cURL</code> project follows well established open source best practices. | |||
== Where's the code? == | |||
Check out the latest [https://github.com/curl/curl source code from github]. | |||
== Practical examples == | |||
=== Download a single website === | |||
The following command | |||
<syntaxhighlight lang="bash" line start="1"> | |||
$ curl https://curl.haxx.se | |||
</syntaxhighlight> | |||
will download the content of the curl website and shows it in the STDOUT. | |||
=== Save the cURL Output to a file === | |||
To save the result of the curl command to a file by using -o/-O options. | |||
* -o (lowercase o) the result will be saved in the filename provided in the command line | |||
* -O (uppercase O) the filename in the URL will be taken and it will be used as the filename to store the result | |||
<syntaxhighlight lang="bash" line start="1"> | |||
$ curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html | |||
</syntaxhighlight> | |||
=== PHP Example === | |||
<syntaxhighlight lang="php" line start="1"> | |||
// Creates a curl resource | |||
$c = curl_init(); | |||
// Sets the URI | |||
curl_setopt($c, CURLOPT_URL, $URL); | |||
// Sets the return the transfer as a string | |||
curl_setopt($c, CURLOPT_RETURNTRANSFER, true); | |||
// Sets the return header | |||
curl_setopt($c, CURLOPT_HEADER, false); | |||
// Sets the follow location | |||
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); | |||
// Sets the timeout | |||
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 7); | |||
curl_setopt($c, CURLOPT_TIMEOUT, 10); | |||
// Sets the Mozila compliance | |||
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); | |||
// Gets the website into a string | |||
$response = curl_exec($c); | |||
// Closes the curl | |||
curl_close($c); | |||
</syntaxhighlight> | |||
== See also == | == See also == | ||
<span class="editsection">[[#content|top]]</span> | <span class="editsection">[[#content|top]]</span> | ||
* [http://bookcurl.haxx.se bookcurl.haxx.se] is the home of this book by Daniel Stenberg. It features easy accessible links to read the book online in a web version or download a copy for offline reading using one of the many different versions offered, including PDF, ePUB and MOBI. | |||
* [https://ec.haxx.se Book], The HTML-representation of the the Book. | |||
== Reference == | == Reference == |
Revision as of 18:00, 11 November 2016
cURL
is a computer software project providing a library and command-line tool for transferring data using various protocols. The cURL
project produces two products, libcurl and cURL. It was first released in 1997. The name originally stood for see URL [1].
The website of cURL
opens with: A command line tool and library for transferring data with URLs [2].
What's cURL
used for
cURL is used in command lines or scripts to transfer data. It is also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets, settop boxes, media players and is the internet transfer backbone for thousands of software applications affecting billions of humans daily.
Who makes cURL
?
cURL
is free and open source software and exists thanks to thousands of contributors.
The cURL
project follows well established open source best practices.
Where's the code?
Check out the latest source code from github.
Practical examples
Download a single website
The following command <syntaxhighlight lang="bash" line start="1"> $ curl https://curl.haxx.se </syntaxhighlight> will download the content of the curl website and shows it in the STDOUT.
Save the cURL Output to a file
To save the result of the curl command to a file by using -o/-O options.
- -o (lowercase o) the result will be saved in the filename provided in the command line
- -O (uppercase O) the filename in the URL will be taken and it will be used as the filename to store the result
<syntaxhighlight lang="bash" line start="1"> $ curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html </syntaxhighlight>
PHP Example
<syntaxhighlight lang="php" line start="1">
// Creates a curl resource $c = curl_init();
// Sets the URI curl_setopt($c, CURLOPT_URL, $URL);
// Sets the return the transfer as a string curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
// Sets the return header curl_setopt($c, CURLOPT_HEADER, false);
// Sets the follow location curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
// Sets the timeout curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 7); curl_setopt($c, CURLOPT_TIMEOUT, 10);
// Sets the Mozila compliance curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
// Gets the website into a string $response = curl_exec($c);
// Closes the curl curl_close($c); </syntaxhighlight>
See also
- bookcurl.haxx.se is the home of this book by Daniel Stenberg. It features easy accessible links to read the book online in a web version or download a copy for offline reading using one of the many different versions offered, including PDF, ePUB and MOBI.
- Book, The HTML-representation of the the Book.
Reference
- ↑ cURL wikipedia
- ↑ curl.haxx.se] Home page of cURL and libcurl.