Download a File from the Internet

DESCRIPTION:

Download a file from the Internet and save the result in a file.

USAGE:

download.file(url, destfile, method="internal", quiet=TRUE, mode="w",
              ..., verbose=!quiet, download.args=list(...))

REQUIRED ARGUMENTS:

url
a character string containing the URL of the resourse to be downloaded. The URL should include the transport protocol e.g. "http://" or "ftp://".
destfile
a character string specifying the name of where the downloaded file is saved.

OPTIONAL ARGUMENTS:

method
a character string specifying the method for the download. Currrently only the default "internal" is supported.
quiet
a logical value, if TRUE, status messages are not printed.
mode
a character string denoting the mode for writing to destfile, as with the open argument to the file function. Common values are: "w" or "wt" to write a text file and "wb" to write a binary file.
...
additional arguments can set using name=value.
verbose
a logical value, if TRUE, status messages are printed.
download.args
a named list of additional arguments. userpwd="username:password" will send the given username:password combination to the website. proxy="proxyhost.com:8080" means to use your proxy server at address hostname:portnumber and proxyuserpwd="username:password" sends that username:password combination to the proxy server. postfields="who=bill&query=age" posts that query string to the website. (You may also paste up a URL with such strings at the end.)

VALUE:

the number of bytes downloaded.

SIDE EFFECTS:

The file destfile is created.

DETAILS:

The function download.file uses the CURL library.

REFERENCES:

The cURL web site: http://curl.haxx.se/.

SEE ALSO:

EXAMPLES:

# Get a copy of Google's home page, store in a tempfile
gtmp <- tempfile("google")
download.file("http://www.google.com", gtmp)
# Remove tempfile when finished:
unlink(gtmp)