Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab Help >> Files : Input/Output functions > getURL

getURL

Download an URL (HTTP, HTTPS, FTP...)

Syntax

filename = getURL(URL);
[filename, [content]] = getURL(URL [, targetDir [, username [, password]]]]);
[filename, [content]] = getURL(URL [, targetFile [, username [, password]]]]);

Arguments

URL

String: An URL. Supported and tested: HTTP, HTTPS, FTP (IPv4 and IPv6)

targetDir

String optional parameter: In which directory the file will be stored (current directory if empty)

targetFile

String optional parameter: Where (and under which name) the file will be stored (current directory if empty)

username

String optional parameter: Username for the websites which require authentication

password

String optional parameter: Password for the websites which require authentication

filename

String: The path to the downloaded file

content

String: The content to the downloaded file

Description

Download a file from an URL

getURL will download a file from a remote URL. By default, getURL will use the same name as provided in the URL. However, under some circumstances (for example, http://www.scilab.org/), the filename is not provided by the URL itself, getURL will rename the file to index.html

content contains the content of a page pointed by an URL.

This function is based on the curl library.

Username and Password can be specified for the websites which required authentication. The authentication method used is the CURLAUTH_ANY provided by CURLOPT_HTTPAUTH parameter of the libcurl library.

IPv6 (and obviously IPv4) are supported out-of-the box by getURL.

Proxy configuration is enabled in this version, it can be modified in the Preferences under the rubric "Internet".

The CURLOPT_FOLLOWLOCATION curl option is activated to make sure the download follow the URL.

getURL is based on libcurl. The version of this library in the official Scilab binary has been compiled with HTTP, HTTPS, FTP and FTPS support. If Scilab has been installed through a packaging system in a distribution, it is likely that other protocols than HTTP, HTTPS and FTPS will work. However, they have not been tested enough.

Examples

// Will download the URL and name the file maths_simulation
getURL("http://www.scilab.org/products/scilab/features/maths_simulation");

// Save the Scilab homepage in the current directory (and rename the file)
getURL("http://www.scilab.org","scilab_homepage.html");

// Download a Scilab example and execute it
myFile = getURL("http://fileexchange.scilab.org/toolboxes/contour3d/10.03/files/contour3d.sci",TMPDIR)
exec(myFile);
contour3d();

// Use authentication
getURL("http://httpbin.org/basic-auth/user/passwd",TMPDIR+"/testfile.html","user","passwd")

// Needs IPv6 connectivity
getURL("http://ipv6.google.com/intl/en_com/images/srpr/logo3w.png")

// Retrieve the content
[myFile, content] = getURL("http://fileexchange.scilab.org/toolboxes/contour3d/10.03/files/contour3d.sci",TMPDIR)

See also

  • splitURL — Split an URL (HTTP, HTTPS, FTP...)

History

VersionDescription
5.5.0 Function getURL() introduced
Report an issue
<< fscanfMat Files : Input/Output functions getmd5 >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 14:57:21 CET 2019