Farscape: Peacekeeper wars
Official trailer        Fan made trailer
TclCurl logo
TclCurl logo small
Main
Docs
Man page
Multi
Share api
Examples
Install
Changes
Todo
Download
Credits

libcurl logo

Getleft logo

For all this examples to work you first have to do:

% package require TclCurl

If Tcl answers something like '0.10.4' you are in business. If it doesn't, please check the install page for possible solutions.

Basic examples

To download a webpage

        package require TclCurl
        curl::transfer -url http://www.curl.com

You can also get information about the transfer:

	curl::transfer -url http://www.curl.com     \
	        -infohttpcode     httpCode          \
	        -infocontenttype  contentType       \
	puts "Http code: $httpCode"
	puts "Content type: $contentType"

The curl::transfer command is used for simple transfers where you don't want to use persistant connections. For more complex operations:

        set curlHandle [curl::init]
        $curlHandle configure -url http://www.curl.com \
                -file "index.html"
        $curlHandle perform

        $curlHandle configure -header 1                \
                -file "anotherfile.html"
        $curlHandle perform

        $curlHandle cleanup

As you can see in this example, it is easy to reuse connections.

Maybe you want to know which files are in a directory of a ftp server:

        curl::transfer -url "ftp://ftp.kde.org/pub/" \
                -ftplistonly 1

Or perhaps something more unusual:

        curl::transfer -url "dict://dict.org/m:curl"

For a better idea of what you can do, you can read the cURL manual page and The art of HTTP scripting.


Andrés García