W3cubDocs

/Octave

36.4.2 URL Manipulation

s = urlread (url)
[s, success] = urlread (url)
[s, success, message] = urlread (url)
[…] = urlread (url, method, param)

Download a remote file specified by its url and return its content in string s.

For example:

s = urlread ("ftp://ftp.octave.org/pub/README");

The variable success is 1 if the download was successful, otherwise it is 0 in which case message contains an error message.

If no output argument is specified and an error occurs, then the error is signaled through Octave’s error handling mechanism.

This function uses libcurl. Curl supports, among others, the HTTP, FTP, and FILE protocols. Username and password may be specified in the URL. For example:

s = urlread ("http://user:[email protected]/file.txt");

GET and POST requests can be specified by method and param. The parameter method is either ‘get’ or ‘post’ and param is a cell array of parameter and value pairs. For example:

s = urlread ("http://www.google.com/search", "get",
            {"query", "octave"});

See also: urlwrite.

urlwrite (url, localfile)
f = urlwrite (url, localfile)
[f, success] = urlwrite (url, localfile)
[f, success, message] = urlwrite (url, localfile)

Download a remote file specified by its url and save it as localfile.

For example:

urlwrite ("ftp://ftp.octave.org/pub/README",
          "README.txt");

The full path of the downloaded file is returned in f.

The variable success is 1 if the download was successful, otherwise it is 0 in which case message contains an error message.

If no output argument is specified and an error occurs, then the error is signaled through Octave’s error handling mechanism.

This function uses libcurl. Curl supports, among others, the HTTP, FTP, and FILE protocols. Username and password may be specified in the URL, for example:

urlwrite ("http://username:[email protected]/file.txt",
          "file.txt");

GET and POST requests can be specified by method and param. The parameter method is either ‘get’ or ‘post’ and param is a cell array of parameter and value pairs. For example:

urlwrite ("http://www.google.com/search", "search.html",
          "get", {"query", "octave"});

See also: urlread.

© 1996–2018 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/interpreter/URL-Manipulation.html